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

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?

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.

11 minute read

Migration to SAP S/4HANA - 5 Key Considerations

Are you prepared for migration to SAP S/4HANA? Discover the 5 key questions all businesses looking to upgrade to SAP's new ERP system should consider.

11 minute read

Exchange of Electronic Invoices with the SAP eDocument Framework

Companies have to increasingly implement e-Invoicing for different countries. This blog post explains how the SAP eDocument Framework can help you.

2 minute read

How Can You Save an IDoc from SAP on Your Hard Drive?

Wondering how to export IDocs as a file on your local computer? We created a handy guide!

5 minute read

Create and Process UBL Documents with Attachments in SAP

Enable your SAP solution for UBL based e-Invoicing over Peppol. Click here for an example case based on the XRechnung in Germany.

6 minute read

IDoc Processing in an SAP ERP System with Transaction BD87

Companies utilising SAP ERP and exchanging documents need a central tool to manage, view and search for IDocs. Transaction BD87 is the answer.

12 minute read

Understand and Interpret the SAP IDoc Control Record EDI_DC40

A correctly filled control header is essential for the identification and processing of IDocs. We show what settings are needed in SAP.

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.