Skip to Content
0
Former Member
Aug 18, 2007 at 11:43 PM

Calling an RFC from an EJB over an Enterprise Connector

45 Views

Hi all,

I would like to call an RFC enabled Function Modul (FuBa) from a BW-System over an EJB in a Web AS environment bei passing SAP Logon Ticket.

To achive this goal, i've generated proxy classes (Enterprise Connector) via NWDS .

If i call enterprise connector localy from an example class (See attachment), it works.

BUT

-

-


if I use the same Code within an EJB, bei correct deployment , it doesn't work. I become an exception, during to establish a connection

What is wrong here ?

What do i have to do in an a EJB-Environment to use an Enterprise Connector ?

Best Regards

A. Büyükyilmaz

ATTACHMENT

-

-


/*

  • Created on 13.02.2007

  • To change the template for this generated file go to

  • Window>Preferences>Java>Code Generation>Code and Comments

*/

package de.xxx.test.ep.main;

import java.sql.Date;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import com.sap.aii.proxy.framework.core.ApplicationFaultException;

import com.sap.aii.proxy.framework.core.SystemFaultException;

import com.sap.mw.jco.JCO;

import de.xxx.yyy.zzz.connectivity.fuba.Anlage_PortType;

import de.xxx.yyy.zzz.connectivity.fuba.Zge_Gerel_Data_For_Kne_Kn_Input;

import de.xxx.yyy.zzz.connectivity.fuba.Zge_Gerel_Data_For_Kne_Kn_Output;

/**

  • @author pg4011

  • To change the template for this generated type comment go to

  • Window>Preferences>Java>Code Generation>Code and Comments

*/

public class GetAnlage {

private JCO.Client mConnection = null;

public boolean connectToSAP(

String client,

String user,

String passwd,

String lang,

String appServer,

String sysNo) {

try {

mConnection =

JCO.createClient(client, user, passwd, lang, appServer, sysNo);

mConnection.connect();

} catch (Exception e) {

e.printStackTrace();

return false;

}

return true;

}

public static void main(String[] args) {

GetAnlage anlage = new GetAnlage();

if (anlage.connectToSAP ("50", "abc", "pwd", "DE", "system", "00")) {

System.out.println("Anlage wird erstellt");

anlage.getData();

System.out.println("");

}

System.exit(0);

}

private void getData() {

// ImportParameter

Zge_Gerel_Data_For_Kne_Kn_Input input = new Zge_Gerel_Data_For_Kne_Kn_Input();

// Hole proxy Instance mit JCO.Client instance

Anlage_PortType proxy = new Anlage_PortType();

proxy.messageSpecifier.setJcoClient(mConnection);

Zge_Gerel_Data_For_Kne_Kn_Output output = new Zge_Gerel_Data_For_Kne_Kn_Output();

input.setI_Bp_Nr("7901514764");

input.setI_View("03");

input.setI_Spras("DE");

Date stichtag = new Date(2006, 9, 22);

input.setI_Stichtag(stichtag);

//Rufe RFC auf

try {

output = proxy.zge_Gerel_Data_For_Kne_Kn(input);

String s = "";

System.out.println(s);

} catch (SystemFaultException e) {

e.printStackTrace();

} catch (ApplicationFaultException e) {

e.printStackTrace();

}

}

}