cancel
Showing results for 
Search instead for 
Did you mean: 

Is't right?

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Thank you very much.

plz read my post : [graydom]error:CM_NO_DATA_RECEIVED

Regards,

Graydom