cancel
Showing results for 
Search instead for 
Did you mean: 

how to call RFC using EJB module.

Former Member
0 Kudos

hi,

I want to call the RFC using EJB module in java. how to do it.

if someone having the code plz post it.

regards,

Shanthakumar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

You can use JRA for this

check the weblog

/people/amol.joshi2/blog/2006/11/27/alerts-from-adapter-modules--the-jra-way

regards

krishna

Former Member
0 Kudos

hi,

if u have any code for calling RFC(either by using jco or ejb). post it.

regards,

Shanthakumar.

Former Member
0 Kudos

did you check the blog.. the blog has sample code...

regards

krishna

Former Member
0 Kudos

/***Start of JRA specific code***//

// Retrive connection factory

InitialContext initialcontext = new InitialContext();

connectionfactory = (ConnectionFactory) initialcontext.lookup("java:comp/env/ConnFactory");

//Request a connection handle:

connection = connectionfactory.getConnection();

//Create a RecordFactory object to get a metadata description

// of the RFC SALERT_CREATE

RecordFactory recordFactory = connectionfactory.getRecordFactory();

// Create Record objects containing all

// necessary information about the RFM.

MappedRecord input = recordFactory.createMappedRecord("SALERT_CREATE");

//Fill in the import parameters and the import table structure data here

input.put("IP_CAT", "ALRT_CAT"); // alert category

// Refer to the SW_CONT structure of the table of RFC SALERT_CREATE

ResultSet inputITContainer = (ResultSet) input.get("IT_CONTAINER");

int tabIndex = 0;

inputITContainer.moveToInsertRow();

inputITContainer.updateString("ELEMENT", "CONT_1");

inputITContainer.updateString("TAB_INDEX", "" + tabIndex++);

inputITContainer.updateString("ELEMLENGTH", "250");

inputITContainer.updateString("TYPE", "C");

inputITContainer.updateString("VALUE","Container_1 value");

inputITContainer.insertRow();

...

...

...

..

inputITContainer.moveToInsertRow();

inputITContainer.updateString("ELEMENT", "CONT_N");

inputITContainer.updateString("TAB_INDEX", "" + tabIndex++);

inputITContainer.updateString("ELEMLENGTH", "250");

inputITContainer.updateString("TYPE", "C");

inputITContainer.updateString("VALUE","Container_N value");

inputITContainer.insertRow();

interaction = connection.createInteraction();

// execute the call with the input parameters.

interaction.execute(null, input);

}catch(Exception e){

// Error handling code goes here

}finally{

try {

if (interaction != null)

interaction.close();

if (connection != null)

connection.close();

} catch (Exception ignored) {

// Do nothing

}

// Pass on module data to the next module in chain, unaltered

return moduleData;

}

Former Member
0 Kudos

hi,

my requriement is passing 2 inputs to the RFC and getting 1 output from the RFC.

for this i need sample code.

regards,

Shanthakumar.

Former Member
0 Kudos

hi,

what are jar to be used when using JRA.

Regards,

Shanthakumar.

Answers (1)

Answers (1)

Former Member
0 Kudos

also check the webservices way

/people/amol.joshi2/blog/2007/01/29/rfc-calls-from-adapter-modulesthe-web-service-way

regards

krishna

Former Member
0 Kudos

Hi all,

I have tried the JRA approach, however, I ran into this issue:

29.05.2012 15:51:34InformationMP: processing local module localejbs/CallSapAdapter
29.05.2012 15:51:34InformationThe application tries to send an XI message asynchronously using connection File_http://sap.com/xi/XI/System.

MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: Could not insert message 9dcfa356-6f6e-403a-0ff4-ef47c5f6abf1(OUTBOUND) into duplicate check table. Reason: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: The resource "SAPPIDDB" does not support two-phase commit and cannot be enlisted in the current transaction, because another non supporting two-phase commit resource is already enlisted for component "ejbContexts/sap.com/com.sap.aii.af.app/com.sap.aii.af.ejb.jar/CallAdapterWithMessageBean" in application "sap.com/com.sap.aii.af.app". Only one of the enlisted resources is allowed to be non two-phase commit compliant.

My code is also trying to call SALERT_CREATE. Exactly the same code as in the example. It somehow seems to have issues after leaving the adapter. Any ideas?

Thanks!

Regards,

Aerv