Vous êtes sur la page 1sur 15

A Step-by-Step Guide on Asynchronous RFC - to -JDBC Scenario Using

SAP PI 7.0
By Deepak Shah, L&T Infotech
Brief Overview:

The purpose of this exercise is to call an RFC from SAP R/3 asynchronously. A function module is used to
send Data to XI / PI. SAP PI will then convert the data in the Standard SQL Format and Insert the data into
the JDBC database tables.
The Data from table 'ZEMP_DET' created in R/3 will be fetched by the RFC 'ZTEST_TIPS_DOI' and sent to
SAP PI. SAP PI will then insert these Records into database tables.
Prerequisites:
1. Basic Knowledge of SAP PI / XI 7.0
2. Business System configuration in SLD is not covered in detail.
3. JDBC drivers should be deployed on SAP PI system
Implementation Steps:
A.) Maintain R/3 System.
A.1) Create RFC in SAP R/3 System (Send Data to SAP PI).
Go to Transaction SE37. Enter the name for functional module. Click on Create.

Define a tables parameter 'ZEMP_DET' table like 'ZEMP_DET' created in R/3.

Save & activate.
A.2) Create RFC Destination in SAP R/3 System.
Create an RFC destination 'RFC_SENDER_DS' of type 'T' in the SAP R/3 system itself (Not in XI System)
Make sure to select radio button Registered Server Program
Enter a Unique Program ID 'RFC2JDBC'.
To find the Gateway Host & service: Goto Transaction SMGW -> Goto -> Parameter -> Display

A.3) Create ABAP Report in SAP R/3 system.
Create an R/3 report that will call the RFC which will send data to SAP XI.
The ABAP code is as follows.
For calling the RFC asynchronously use In Background task command.
Also use 'Commit work' at the end of RFC call.
*&------------------------------------------------------------------*
*& Report ZTEST_WEBSERVICE
*&------------------------------------------------------------------*
REPORT ztest_webservice.
DATA: ssh_no TYPE char30.
DATA : g_zemp_det LIKE zemp_det OCCURS 0 WITH HEADER LINE.
DATA : l_temp TYPE string.
SELECT * FROM zemp_det INTO CORRESPONDING FIELDS OF TABLE g_zemp_det.
CALL FUNCTION 'ZTEST_TIPS_DOI' in background task DESTINATION 'RFC_SENDER_DS'
* IMPORTING
* count = l_temp
TABLES
zemp_det = g_zemp_det
EXCEPTIONS
rfc_external_abort = 1
deliveryexception = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
commit work.
WRITE : 'test'. "'count = ' , l_temp.
B.) Maintain SAP XI / PI System.
B.1) Maintain SLD (System Landscape Directory)
This Document does not contain configuration steps for creating the Business System, Technical system,
Product & Software component. It is assumed that the sender and receiver Business Systems are already
created along with corresponding Technical System, Product, Software components. Also the Software
Component is imported into Integration Repository.
In this Example,
Sender Business System: CX1_Business_System
Receiver Business System: TBIT40_SQLSERVER_BS
Software Component: TBIT40_DS_SWCW, 2.0 of sap
B.2) Maintain IR (Integration Repository)
B.2.1 Importing RFC from SAP R/3 System
Double Click on your Software Component in the Integration Repository.
Select the radio Button 'Import of RFC and IDoc interfaces from SAP system Permitted'
Enter the Connection Data for Import from SAP System
Click on SAVE & Activate.
Now right click on Imported Object under your Software Component and click on Import of SAP Objects.

Click here to continue...

































A Step-by-Step Guide on Asynchronous RFC - to - JDBC Scenario Using
SAP PI 7.0
...Previous
Give the relevant R/3 System information

Select the RFC "ZTEST_TIPS_DOI" and click continue

Click finish to start import. Once the RFC is successfully imported save & activate it.

Note: We don't require any Data Type, Message Type and Message Interface for Sender side as RFC
itself will be used for Sender Data Type, Message Type and Message Interface.
B.2.2 Create Data Type for Receiver:
Go to Interface Objects tab in your namespace.
Go to Data type and Click on new
Here we will create data type "masterData". The structure is as follows.

B.2.3 Create Message Type for Receiver:
In the Left Frame, Right Click on the Node Message type and select "New".
Create message type by the name "masterData_MT".

B.2.4 Create Message Interface for Receiver:
In the Left Frame, Right Click on the Node Message Interface and select "New".
The Name of the Message Interface will be "masterData_MI"
The Interface Should be INBOUND & ASYNCHRONOUS
Input message type "masterData_MT"
Save & activate.

B.2.5 Create Message Mapping:
In the left frame, right click on the Message Mapping under "Message objects" tab and select "new".
The Name of the Message Mapping will be test_DS.
Source message ZTEST_TIPS_DOI
Target message masterData_MT
Perform the Mapping of each target field with suitable source fields as per your requirements.
Save & activate.

B.2.6 Create Interface Mapping:
Now Create the Interface Mapping test_DS_IM
In the left frame, right click on the Interface Mapping under Message objects tab and select "new"
Source Interface: ZTEST_TIPS_DOI
Target Interface: masterData_MI
Mapping Program: test_DS. Save & activate

Click here to continue...






























A Step-by-Step Guide on Asynchronous RFC - to - JDBC Scenario Using
SAP PI 7.0
...Previous
B.2) Maintain ID (Integration Directory)
B.2.1 Create Configuration Scenario
Open Integration Directory
Create a new Configuration Scenario or use an existing one. In our example scenario rfc2jdbc will contain
all our scenario objects.

B.2.2 Add Sender and Receiver Business System.
Add sender and receiver business System in your Configuration scenario
The business Systems used in this scenario is as follows.
1. CX1_Business_System
2. TBIT40_SQLSERVER_BS
B.2.3 Create Sender Communication Channel.
Go to your Sender Business System, right click on communication channel and select new.
Create a new receiver communication channel RFC_Test1
Select the Sender Radio button to identify the channel as sender.
Adapter type: RFC
Transport Protocol: RFC
Message Protocol: RFC (RFC XML)
Adapter Engine: Integration Server.
Program ID: RFC2JDBC (should be same as used in RFC Destination)
Save & activate.

Enter the RFC Metadata Repository Parameter as follows. i.e the Sender system details.

B.2.4 Create Receiver Communication Channel.
Go to your Receiver Business System, right click on communication channel and select new.
Create a new receiver communication channel MSAccess_RECV_DS2.
Select the Receiver Radio button to identify the channel as receiver.
Adapter type: JDBC
Transport Protocol: JDBC 2.0
Message Protocol: XML SQL Format
Adapter Engine: Integration Server.
JDBC Driver: sun.jdbc.odbc.JdbcOdbcDriver
Save & activate.

B.2.5 Create Receiver Determination.
Create a new Receiver Determination.
Sender service: CX1_Business_System
Interface: ZTEST_TIPS_DOI
Namespace: urn:sap-com:document:sap:rfc:functions
Enter your receiver business system TBIT40_SQLSERVER_BS. Save.

B.2.6 Create Interface Determination.
Create a new Interface Determination.
Sender service: CX1_Business_System
Interface: ZTEST_TIPS_DOI
Namespace: urn:sap-com:document:sap:rfc:functions
Inbound Interface: masterData_MI
Namespace: urn:sap-com:Tipsinterface
Interface mapping: test_DS_IM
Save & activate

B.2.7 Create Receiver Agreement.
Sender service: CX1_Business_System
Receiver service: TBIT40_SQLSERVER_BS
Inbound Interface: masterData_MI
Namespace: urn:sap-com:Tipsinterface
Select the Receiver Communication Channel MSAccess_RECV_DS2 created above.
Save & activate.

B.2.8 Create Sender Agreement.
Sender service: CX1_Business_System
Interface: ZTEST_TIPS_DOI
Namespace: urn:sap-com:document:sap:rfc:functions
Select the sender Communication channel RFC_Test1 created above.

Testing the Scenario
Go to transaction SE 38 and execute the Report ZTEST_WEBSERVICE.
A test message will be displayed on screen.

Go to transaction SXMB_MONI in XI server to view the status of the messages. Messages should have
successful Status.

Open the database table to see if the records have been inserted into tables or not.