03 Java Connector RFC Provider Service SOL

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

JCO RFC Provider Service, Solutions

Unit: JCO RFC Provider Service


Topic: Making a remote call from SAP R/3

At the conclusion of this exercise, you will be able to:


• How to make an outbound call from SAP R/3 to WAS.

1. Development Objectives
Creating a J2EE Project and using the SAP Java Connector (SAP JCO) process a
function call made from SAP R/3. The J2EE Project will contain an EAR
application and an EJB-JAR application. The EJB Project contains a Stateless
Session Bean with a processFunction () business method that will be called by the
JCO RFC Provider Service in WAS. The EJB JNDI name is the name of the
calling SAP R/3 function module Z_JCO_RFC_PROVIDER.

2. Result
As a result of the exercise you will be able to see the export parameter value of the
function module populated from J2EE.
3. Prerequisites
3-1 You have configured a RFC Destination in Visual Admin JCO Rfc
Provider tab and it is running.

3-2 You have configured a destination in SM59 and tested the link to the J2EE
Server.
3-3 The function module Z_JCO_RFC_PROVIDER is defined in SAP R/3.
3-4 You have opened the Netweaver Developer Studio, imported the projects
and selected the J2EE perspective.
4. Overview Developing

For your convenience, you can start


developing with a predefined Project.
The graphics on the left shows the J2EE
Enterprise Application Project (EAR)
and EJB Project imported into the
Developer Studio Workplace.

Z_JCO_RFC_PROVIDERBean
The Bean implementation class.
This contain the business method public
void processFunction(JCO.Funtion fn)
which is called by the JCO Rfc service.

4. Complete the business method code


4-1 Setup EJB Project Build Path
• Right Click on TestEJB -> Properties ->Java Build Path->Libraries
->Add Variable -> Choose WD_RUNTIME -> Extend -> Goto
com.sap.mw.jco\lib\ -> Select sapjco.jar
• Right Click on TestEJB -> Properties ->Java Build Path->Libraries
->Add Variable -> Choose SAP_LOGGING_LIB_HOME->
Extend -> Goto lib\ -> Select logging.jar
4-2 Setup EAR references
• Open application-j2ee-engine.xml file. Goto General tab
• Click Add -> Select Library/Interface -> sap.com ->
com.sap.mw.jco. Make the Reference type to ‘weak’
• Click Add -> Select Library/Interface -> sap.com ->
com.sap.tc.Logging. Make the Reference type to ‘weak’

4-3 Navigate to the function public void processFunction(JCO.Function)


in the Bean Z_JCO_RFC_PROVIDERBean. Add the following code
to the method.
// Get the import parameters for the function module
JCO.ParameterList importList =
function.getImportParameterList();
logger.infoT("The value sent from SAP for UNAME is " +
(String)importList.getValue("UNAME"));
// Set the export parameter value for the function module
JCO.ParameterList export =
function.getExportParameterList();
export.setValue("From EJB", "RETURN");

function.setExportParameterList(export);

5. Deploying the Application


5-1 Right Click on the TestEJB Project and “Choose Build EJB Archive”.
5-2 Right Click on the JCORfcProviderProjectEAR and “Choose Build
Application Archive”.
5-3 Right Click on the JCORfcProviderProjectEAR.ear file and “Choose Deploy
to J2EE Engine”

6. Testing the Application


Login to SAP R/3, Goto transaction SE37, Enter function module name
Z_JCO_RFC_PROVIDER and Click F8.

On successful execution the export parameter will have the value ‘From EJB’
populated from the EJB business method.
To View the values sent from SAP R/3 use the Visual Admin logviewer –

You might also like