This blog post will give you the overview to use IDOC as XML.
Introduction:
IDOC is a standard data structure used in SAP applications to transfer data to and from SAP system applications and external systems.
More details about IDOCs can be found here:
https://wiki.scn.sap.com/wiki/display/ABAPConn/IDoc+Overview
https://wiki.scn.sap.com/wiki/display/Community/Inbound%20and%20Outbound%20Idoc%20Configuration%20St...
https://wiki.scn.sap.com/wiki/display/Community/Inbound%20and%20Outbound%20Idoc%20Configuration%20St...
Now we are going to see how IDOC can be sent as XML over HTTP to external systems.
Procedure:
The below are the steps to be followed:
- Create the RFC destination to send the outbound IDOC.
- Maintain the Outbound Port.
- Create Partner Profile.
- Generate the IDOC.
1. Create the RFC destination:
- Transaction Code to create RFC destination is SM59
- Select the connection type as G (HTTP Connection to External Server)
- In order to send the outbound IDOC to we need to maintain the RFC destination in S4.
- RFC destination will going to contain the external system endpoint including Host, Path Prefix. Also maintain the basic authentication.
The below is the RFC destination created.
2. Maintain the Outbound Port
- Transaction Code to create PORT is WE21.
- XML HTTP port is required in order to convert the IDOC into XML
- Create the XML HTTP Port in S4 and maintain the RFC destination as below.
3. Create Partner Profile
- Transaction Code to create Partner Profile is WE20
- Partner profile need to be maintained in S4 with the outbound port which we have created in WE21.
4. Generate the IDOC.
Now Create a sample program to populate the control record and IDOC segments and call the function modules 'MASTER_IDOC_DISTRIBUTE' and
'DB_COMMIT'.
Please refer to the below blog to get the sample code.
https://wiki.scn.sap.com/wiki/display/ABAP/Outbound+Idocs+by+ALE
Now execute the program to send the data to external systems using IDOC as XML.
Once the IDOC is triggered, the system will convert the IDOC data into XML file and post to end-point URL maintained in RFC destination of IDOC port.
Conclusion:
By following these steps, we can send the IDOC as XML over HTTP protocol.