Chat with us, powered by LiveChat
3 minute read

How to Save an IDoc as an XML?

IDocs in SAP

IDocs are the central import and export format of SAP ERP systems. They can therefore be used for data exchange with other software systems, e.g. when transferring customer data from a CRM system. IDocs are also particularly relevant in electronic data interchange (EDI) with external suppliers and customers.

No matter which application scenario, you will often encounter the issue where you will need a specific IDoc as an XML file on your local hard drive. Repeatedly exporting files through a partner profile configured in transaction WE20 is ill advised due to uncontrolled side effects, e.g. repeating DESADV dispatches to clients.

The XML file is thus the best way forward, as it has many advantages and can for example be used to debug incorrect behaviour in software downstream from SAP. There are various functions available for exporting IDoc data in SAP. In a previous article we explained how to export IDoc data in Excel format. SAP also offers functions for exporting an IDoc as an XML file however.

In the following section, we will present you with an approach where it is not required to use your own ABAP code. With this approach, you will not have to create an ABAP code or transport it on a P-level. This method is also well suited for debugging on a P-system, under the condition that the user has the needed permissions for transaction SE37.

Webinar - Achieving Deep ERP SAP Integration
View our webinar in which we look in depth at EDI integration in SAP

Export an IDoc as XML

To export an IDoc as an XML, you will first need to open transaction SE37.

Transaction SE37 in SAP
Transaction SE37 in SAP

Enter the element IDOC_XML_TRANSFORM in the function block and execute it by clicking on F8. As you can see on the picture below, the IDoc is now shown as an XML data.

Enter the IDoc Number
Enter the IDoc Number

Now enter the IDoc number that is to be exported in the DOCNUM field. Before the value can be entered, the zeros must be removed. Then execute the transaction with F8. The IDoc is now displayed as an XML file, as shown in the following image:

XML Representation of the IDoc
XML Representation of the IDoc

Pressing ctrl+A, ctrl+C or ctrl+V will allow you to view the XML content with any editor.

As shown in the screenshot, the generated XML file has a small flaw: the opening angle brackets (< und </) of the elements are followed by spaces, and the closing angle brackets (>) have spaces before them. This means that this XML is not formatted properly.

To correct this, you can copy the XML data into an editor (Notepad++ e.g.) and search and replace the spaces around the angle brackets.


By using the method, you will be able to quickly and easily export IDoc data as XML files from an SAP system. The only disadvantage is that the resulting XML file is not valid and needs to be corrected with an editor, before it can be transmitted to further applications.

Do you have any questions?

Do you still have questions about Idocs and XML data? Feel free to contact us or check out our chat, we would love to help you!


most read

Keep on reading

Cookie Settings

All marketing cookies
LinkedIn (cn_LinkedINActive)
LinkedIn uses cookies so as to provide you with a personalised user experience and show you relevant content.
Google Analytics (cn_AnalyticsActive)
Used to send data to Google Analytics about the visitor's device and behaviour. Tracks the visitor across devices and marketing channels.
Facebook (cn_FacebookActive)
Used by Facebook to display a range of promotional products, such as third-party real-time bidding.
Google Adwords (cn_AddWordsActive)
Used to identify users visiting the website via Google Ads.
Pardot (cn_PardotActive)
Pardot uses cookies to make your interactions with our website more meaningful. They help us better understand what you’re looking for, so we can tailor content for you