cancel
Showing results for 
Search instead for 
Did you mean: 

Call an RFC from a Bean Class

Former Member
0 Kudos

Hi,

My question is how to call an RFC from a bean Class (stateless Session Bean). I have followed a link and wrote a following class :

public class Bapi1

{

public static void main(String args[])throws ApplicationFaultException, SystemFaultException

{

String aMonth[] = null;

String aMonthVal[] = null;

JCO.Client jcoclient = null;

Yfunc001_Output output = null;

try {

jcoclient = JCO.createClient("Client","Username","Password","Lang","SAP Application System"," SAP System Number");

try {

jcoclient.connect();

System.out.println(""+ jcoclient.getASHost()+ jcoclient.getClient()+ jcoclient.getLanguage()+ jcoclient.getSystemNumber()jcoclient.getUser()jcoclient.isValid());

} catch (RuntimeException e2) {

// TODO Auto-generated catch block

e2.printStackTrace();

}

} catch (Exception e) {

// TODO Auto-generated catch block

System.out.println(e.getLocalizedMessage());

e.printStackTrace();

}

Yfunc001_Input input = new Yfunc001_Input();

Graph_PortType mytype = new Graph_PortType();

mytype.messageSpecifier.setJcoClient(jcoclient);

try {

output = mytype.yfunc001(input);

} catch (SystemFaultException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (ApplicationFaultException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

jcoclient.disconnect();

YstructType_List list = output.get_as_listItab();

int listsize = list.size();

for (int i = 0; i < listsize; i++) {

YstructType elem = list.getYstructType(i);

aMonth<i> = elem.getMth();

aMonthVal<i> = elem.getMval();

}

}

}

When I try to Execute this class I get the following Exception

java.lang.NoClassDefFoundError

* at com.sap.mw.jco.MiddlewareJRfc$Client.connect(MiddlewareJRfc.java:882)*

* at com.sap.mw.jco.JCO$Client.connect(JCO.java:3159)*

* at com.ltil.fusionejb.Bapi1.main(Bapi1.java:32)*

Exception in thread "main"

I get an Error on Line : jcoclient.connect();

What All libraries I need to install? Please List down the Steps if possible. Points with be awarded...

Thanks,

Prasanna.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Add the following jar to the classpath,

<Drive>:/usr/sap/<SID>/JC00/j2ee/cluster/server0/bin/ext/com.sap.mw.jco/jrfc.jar

Hope this helps in solving the issue !

Regards,

Srinivasan T

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Thanks for the reply.... Got it....

Regards,

Prasanna.

Edited by: Prasanna Joshi on Dec 27, 2007 2:19 PM

Former Member
0 Kudos

Hi,

Good to hear that the problem is solved !

Please mark the thread as solved and close it.

Regards

Srinivasan T