4 minute read

How to Save an IDoc as an XML - A Guide

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. Further, much like saving an IDoc to your hard drive, deleting an IDoc, or reprocessing an IDoc, exporting an IDoc as an XML isn’t too difficult.

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.

White Paper - EDI Integration in SAP

Export an IDoc as an XML

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


Transaction SE37 in SAP
Transaction SE37 in SAP

© 2020. SAP SE or an SAP affiliate company. All rights reserved. Used with permission of SAP SE.

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

© 2020. SAP SE or an SAP affiliate company. All rights reserved. Used with permission of SAP SE.

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

© 2020. SAP SE or an SAP affiliate company. All rights reserved. Used with permission of SAP SE.

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.

Summary

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!

 

SAP ERP and SAP S/4HANA are the trademarks or registered trademarks of SAP SE or its affiliates in Germany and in several other countries. 

Subjects

most read

Keep on reading

2 minute read

How to End Another User's SAP Session

Unable to edit a crucial document in SAP® because you're locked out? Learning how to end another user's SAP session will solve this issue.

3 minute read

Finding Translations for SAP® Terminology

Using the correct translations for SAP® terminology is important in international projects. Discover how to find these quickly.

2 minute read

How to Save an IDoc Parser Report to a Local File

In this short and simple guide we show you how to save an IDoc parser report to a local file in just a couple of easy steps.

6 minute read

How to Debug SAP Message ME161 - "The Notified Quantity Exceeds the Ordered Quantity"

Don't know how to fix SAP error message ME161 "The notified quantity exceeds the ordered quantity"? In this article we break it down.

6 minute read

SAP® EDI Project Roles - A Breakdown

Learn the various EDI project roles involved in achieving successful EDI integration in SAP systems and how the different roles interact.

3 minute read

How to create an SAP transaction code

Want to know how to create an SAP transaction code for an existing ABAP program so that you can easily call the program?

9 minute read

Alternative Solutions for EDI Data Exchange with SAP PI and SAP PO

Discover the three possibilities when it comes to implementation of electronic data interchange (EDI) in SAP Process Integration or SAP Process Orchestration (SAP PI/PO).

6 minute read

How to Set Up and Manage Automatic SAP Jobs

SAP jobs can be used to automate processes in SAP ERP so they can be carried out without user intervention. We explore the key features.

4 minute read

IDoc Status Change in SAP ERP

IDoc statuses are not always the clearest - particularly when errors occur. In this article we explain how to change IDoc status as required.

5 minute read

How Can I Add an Entry to an SAP Table?

In this article we show how to add entries to an existing SAP table - even if it does not have its own maintenance dialog.

5 minute read

Alternatives to the Seeburger PI Adapter

The end of maintenance for the Seeburger PI Adapter is imminent. What alternatives are there and which is the best suited for your business?

4 minute read

IDocs in SAP S/4HANA: The Differences to SAP ECC 6.0

The change to S/4HANA also impacts the format of IDocs. In this article we explore IDocs in S/4HANA and the new and changed elements.

We use cookies to provide an optimal website experience. You decide which one you want to allow. Depending on the setting, however, not all functionalities may be available to you. Data protection & imprint.