Download Quick Guide û EDI IDoc Interfacing to SAP ECC from External System...
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Applies to: Up to ECC 6.0. For more information, visit the ABAP homepage.
Summary IDoc Interface: EDI Application Scenario The application scenarios describe business processes in which EDI can be implemented. Consequently, two partners are always involved in these processes: The sender and the recipient of the EDI message. The scenarios should describe a business process as simply as possible, while remaining realistic. The process described here in this document can serve as templates or starting points for customer-defined business processes. The scenario covered in this guide involves the IDoc interface, wherein, the data is received from an external system and the subsequent processing in the R/3 system is done. This processing of the data in the R/3 system is called Inbound Processing or also Inbound Author:
Rohit Khan
Company: SAP India GD Created on: 15 Nov 2010
Author Bio Rohit is working as a SAP Netweaver Consultant at SAP India GD. He is based out of Gurgaon facility.
[email protected].
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Table of Contents Introduction ......................................................................................................................................................... 3 Dependencies/Pre-requisites.............................................................................................................................. 3 Technical Process steps ..................................................................................................................................... 4 Customizing Steps .............................................................................................................................................. 5 Demonstration .................................................................................................................................................... 5 Related Content ................................................................................................................................................ 15 Copyright........................................................................................................................................................... 16
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Introduction This short ‘How to Guide’ will guide the SAP Technical Consultants to bridge the interface between an R/3 and External System. This scenario is based on an EDI scenario. Example: The following figure shows the creation of DEBMAS and ADRMAS IDoc in the R/3 from an External System through flat file
Dependencies/Pre-requisites
Basic ABAP knowledge Knowledge of IDoc interface Knowledge of EDI process
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 3
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Technical Process steps The scenario covered in this guide involves the IDoc interface and the corresponding EDI settings, wherein, the data is received from an external system and the subsequent processing in the R/3 system is done. This processing of the data in the R/3 system is called Inbound Processing or Inbound Inbound Process Flow: Receiving Data from External System Let us now understand some basic concepts about Inbound Processing,
External System Send data to R/3 System Transfer
R/3 System Check port & partner, generate IDoc Yes
Post document No
No
Error Handling
Inbound processing includes:
Receiving IDoc data from an External System through flat files
Creating the Inbound IDoc
Finding the correct processing type via Partner Profile
Creating the Application Document
For the above process to work, we must maintain the IDoc interface for Inbound processing:
In the Partner Profile (WE20), the receiving system must be maintained as the partner for inbound processing and the Message Types should be maintained
The IDoc is passed directly to the Application Function Module according to the Partner Profile settings and processed according to Process Code
An Application IDoc is created in the database
Along with the above settings, we need to write an Interface Program. This interface program will pick the data file that is dumped into the Application Server
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 4
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
We need to define this flat file as Logical File using the T-Code FILE
We need to assign Physical Path to the Logical Path created above
In the program we also need to take care of the mapping. This will involve mapping the source fields from the file to the respective fields in the segments of the corresponding Message Types
Finally we will call the respective function module for IDoc processing
Customizing Steps Following customizing need to be taken care: Creation of Logical File path Creation of Partner Profile, involving the following
Defining the Partner Type - Logical System
Defining the Inbound parameters
Assigning the corresponding Process Code (Process code identifies the type of data processing for inbound processing. The IDoc interface uses the process code to find the business process which controls the conversion of the IDoc into the SAP document)
Choosing the Mode of Processing
Trigger by background program
Trigger immediately
Demonstration Now we will see the Demo of all the steps involved as discussed above: 1. Create a Logical File name using T-Code - FILE. Click on the ‘New Entries’ create new entry
SAP COMMUNITY NETWORK © 2010 SAP AG
button to
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 5
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
2. Define a Logical file path. Click on ‘New Entries’ button after you place the cursor on the Folder 'Logical File Path Definition'. Enter the required values and save
3. Assign the Physical Path to the Logical Path in the similar fashion as done above, after you place the cursor on the folder 'Assignment of Physical Path to Logical Path'
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 6
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
To get the Physical file name from the Logical file path created above, we will use the standard function module 'FILE_GET_NAME'. This function module converts a logical file name to the corresponding physical file name and path for the hardware platform concerned.
The below example is for demo:DATA lv_filename
TYPE localfile.
CALL FUNCTION 'FILE_GET_NAME' EXPORTING client = sy-mandt logical_filename = p_file operating_system = sy-opsys IMPORTING file_name = lv_filename EXCEPTIONS file_not_found =1 OTHERS = 2. IF sy-subrc 0. MESSAGE e048(/asu/general) WITH lv_filename. ELSE. OPEN DATASET lv_filename FOR INPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS. IF sy-subrc 0. MESSAGE e004(/asu/general) WITH lv_filename. ELSE. ASSIGN w_data TO . DO. READ DATASET lv_filename INTO . IF sy-subrc EQ 0. MOVE-CORRESPONDING TO w_data. APPEND w_data TO t_data. CLEAR w_data. ELSE. EXIT. ENDIF. ENDDO. CLOSE DATASET lv_filename. ENDIF. ENDIF.
Note:
Here t_data is nothing but the internal table which we will populate with the file data and w_data is the work area, and, is the field symbol of type of the structure of t_data
With OPEN DATASET you can use ENCODING (NON-UNICODE or DEFAULT) statement depending upon the character representation in which the content of the file is handled
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 7
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
4. The system will prompt you for the transport request. Save it. After we have defined a logical file path, the next step is to create a Partner 5. Define Partner Profile using T-Code - WE20 a. In the Inbound Parameters, make entries for the Message Type. In our example, we have entered DEBMAS and ADRMAS Note: You must maintain the Partners with whom you communicate via IDoc in the Partner Profiles: choose the message to be sent to the partner and define the path to be used, as well as how inbound messages are processed
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 8
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
b. Select the Message Type ADRMAS/DEBMAS (Ex. below) and click on ‘Detail’ button to further specify the attributes like Process code and Inbound options
SAP COMMUNITY NETWORK © 2010 SAP AG
screen
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 9
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Let us see, what the above settings stand for o
Process Code - A process code identifies the type of data processing for inbound processing
o
Use - The IDoc interface uses the process code to find the business process which controls the conversion of the IDoc into the SAP document. You can also change the ALE option and processing type in the Process Code. See below.
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 10
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
Ex. DEBM - EDI Customer master. This process code contains FM to process the inbound IDoc
Process by Function Module - Using this option in the Partner profile we can determine the processing of IDoc. There are two options available for this o
Trigger by Background program - This option can be chosen if you want your interface program to create the IDoc when the program is run in background mode. This will create the IDoc with status 64 (IDoc ready to be transferred to the application)
o
Trigger immediately - This will immediately create the application IDoc and post it in the system, with the relevant status 53 (IF successfully posted)
After all these settings are done, we need to write the interface program for populating the IDoc structure EDI_DC40 and EDI_DD40 and call the relevant FM for generating and IDoc
The following figure will explain the process in more detail
SAP COMMUNITY NETWORK © 2010 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 11
Quick Guide – EDI/IDoc Interfacing to SAP ECC from External System
ABAP to create and Post IDoc Fill structure: EDI_DC40 Flat Files from Application layer
Legacy System
& Fill Tables: EDI_DD40 Call FM IDOC_INBOUND_SINGLE
The EDI_DC40 structure needs to be populated with the fields, MSGTYP, IDOCTYP, DIRECT, SNDPOR (SAP+SY-SYSID), SNDPRN, SNDPRT, RCVPOR (SAP+SY-SYSID), RCVPRN, RCVPRT. See example below...
*&---------------------------------------------------------------------* *& Form FILL_IDOC_HEADER *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text *