Upload
krishnamf01
View
506
Download
16
Embed Size (px)
Citation preview
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
1/14
A Step-by-Step Guide on Asynchronous RFC - to -JDBC ScenarioUsing 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 isused to send Data to XI / PI. SAP PI will then convert the data in the Standard SQL Format and Insertthe 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' andsent 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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
2/14
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 XISystem)
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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
3/14
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 taskcommand.
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_tempTABLESzemp_det = g_zemp_det
EXCEPTIONSrfc_external_abort = 1deliveryexception = 2OTHERS = 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, Technicalsystem, Product & Software component. It is assumed that the sender and receiver BusinessSystems 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
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
4/14
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 SAPObjects.
Give the relevant R/3 System information
Select the RFC "ZTEST_TIPS_DOI"and click continue
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
5/14
Click finish to start import. Once the RFC is successfully imported save & activate it.
Note: We don' t requireany Data Type, Message Typ e and Message Interface for Sender side asRFC itself wil l be us ed 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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
6/14
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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
7/14
B.2.5 Create Message Mapping:
In the left frame, right click on the Message Mappingunder "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 Mappingunder Message objectstab and select "new"
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
8/14
Source Interface: ZTEST_TIPS_DOI
Target Interface: masterData_MI
Mapping Program: test_DS. Save & activate
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 willcontain all our scenario objects.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
9/14
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 buttonto 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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
10/14
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 buttonto identify the channel as receiver.
Adapter type: JDBC
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
11/14
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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
12/14
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
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
13/14
Receiver service: TBIT40_SQLSERVER_BS
Inbound Interface: masterData_MI
Namespace: urn:sap-com:Tipsinterface
Select the Receiver Communication Channel MSAccess_RECV_DS2 createdabove.
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.
8/10/2019 A Step-By-Step Guide on Asynchronous RFC - To -JDBC Scenario Using SAP PI 7.0
14/14
A test message will be displayed on screen.
Go to transaction SXMB_MONI in XI server to view the status of the messages. Messages shouldhave successful Status.
Open the database table to see if the records have been inserted into tables or not.