Skip to Content
0
Former Member
Dec 24, 2007 at 12:37 PM

Call an RFC from a Bean Class

13 Views

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.