Skip to Content
Technical Articles

Sending IDOC as XML (Outbound API)

This blog post will give you the overview to use IDOC as XML.


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:

Now we are going to see how IDOC can be sent as XML over HTTP to external systems.


The below are the steps to be followed:

  1. Create the RFC destination to send the outbound IDOC.
  2. Maintain the Outbound Port.
  3. Create Partner Profile.
  4. Generate  the IDOC.

1. Create the RFC destination:

  1. Transaction Code to create RFC destination is SM59
  2. Select the connection type as G (HTTP Connection to External Server)
  3. In order to send the outbound IDOC to we need to maintain the RFC destination in S4.
  4. 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

  1. Transaction Code to create PORT is WE21.
  2. XML HTTP port is required in order to convert the IDOC into XML
  3. Create the XML HTTP Port in S4 and maintain the RFC destination as below.


3. Create Partner Profile

  1. Transaction Code to create Partner Profile  is WE20
  2. 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.

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.


By following these steps, we can send the IDOC as XML over HTTP protocol.





You must be Logged on to comment or reply to a post.
  • Hi Lakshmi

    Thanks for the article!

    For the step #4 (generate IDOC)  you may not even need to create custom ABAP report. There are some standard tcodes like WE19 (test tool for IDOCs), BD10 (send material), BD12 (send customer), BD14 (send vendor) and smore more BD* transactions that allow generating standard IDOCs types out of the box.


    Thanks & regards,


    • Thanks for your comments. Yes, its all based on the requirement. We have a specific requirement using custom IDOC and trigger from custom program.

          • We can create REST APIs in ABAP using SAP Gateway even in ECC (I did it in an EHP6 system with ABAP 7.31, so don't even have to be latest and greatest). These also have monitoring and reprocessing tools. And REST is designed to work over HTTP and can provide either XML or JSON format.

            There is a lot of information on this online, SAP Gateway tag on SCN would be a good start.

          • Not sure what AIF is... There is an error log transaction in SAP Gateway where we can view the error messages and reprocess the request too.

            This particular scenario is outbound though, so that would not apply (and we do not "reprocess" outbound IDocs either, they can only be sent again if in error status). The difference between IDoc and API-based scenario is that the outbound IDocs are "pushed" from SAP while APIs are called from outside (i.e. data is "pulled" from SAP). So for the outbound interface, there is nothing to reprocess on SAP side, the API call can simply be repeated by the other side.

            In any case, I'd encourage to look into REST API / SAP Gateway as a replacement for custom IDocs. If anything, you'd learn more valuable skills developing the APIs.