on 06-16-2005 7:37 AM
I create a BAPI in the SAP client, and it can be run in the SAP Client.
then It must can be run in the java application with jco,cann't it?
Hi wang,
Surely we can run it from JAVA through JCo Client, you have to follow some steps...
Study this sample program to call a BAPI/RFC
package com.satyam.callrfc;
import com.sap.mw.jco.JCO;
import com.sapportals.portal.prt.component.*;
public class rfc extends AbstractPortalComponent
{
private JCO.Client jcoClient;
// proxy for rfc you already assigned...
Insert_pgm_PortType insFunc=new Insert_pgm_PortType();
Zinsert_Pgm_Input ip=new Zinsert_Pgm_Input();
Zinsert_Pgm_Output op=new Zinsert_Pgm_Output();
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
this.connect();
insFunc.messageSpecifier.setJcoClient(jcoClient);
//setting input params
ip.setAssociate_Id1("44");
ip.setCourse_Objt1(2);
ip.setQlty_Content1(5);
ip.setSeq_Content1(2);
ip.setTraining_Id1("22");
try{
//calling rfc
op=insFunc.zinsert_Pgm(ip);
}catch(Exception e){}
//display output
response.write(op.getMessage());
this.disconnect();
}
private void connect() {
try {
jcoClient =
JCO.createClient("client","userid","password","EN","application_system","system_no");
jcoClient.connect();
} catch (Exception e) {
System.out.println("Error connecting to SAP ::" + e.getMessage());
e.printStackTrace();
}
}
private void disconnect() {
try {
jcoClient.disconnect();
} catch (Exception e) {
System.out.println(
"Error dis-connecting to SAP ::" + e.getMessage());
e.printStackTrace();
}
}
}
Hope it clears your doubts.
Regards,
Narinder Hartala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.