How to Download a iDoc to XML File

If you want to download iDocs as files, there are several standard SAP options. But, if you want to convert an iDoc in your SAP system as an XML, capabilities and limited. You may need to download an iDoc created in the system in XML format for multiple reasons. You may want to communicate iDoc samples in XML format with third party systems for requirement analysis purposes. Especially in integration scenarios with external third party systems before setting up the actual interface, you may be required to share sample iDocs in XML formats with the third party system owners. The ABAP program I have created to convert a sample iDoc to a local XML file will be helpful in such scenarios.

In this article we will discuss:

  1. Custom ABAP Z Program Logic to Download or Convert iDocs to XML files.

  2. Alternative Methods to Download iDocs as XMLs.

  3. How to download iDoc data to other different file formats such as HTML, Spreadsheet, text etc.

 

1. Custom Z ABAP Program to Download/Convert iDocs to XML files.

Selection screen:

Basic selection screen with two parameters to enter the iDoc number and the local directory path XML file would be saved. File name will be defaulted to idoc_<idoc number>.xml. More on save file dialog can be found in my previous blog post.

selection screen of ABAP program to download iDoc to XML file.
selection screen of ABAP program to download iDoc to XML file.

 

Output:

iDoc xml will be downloaded to given location in file path.

Download iDoc XML to local drive using ABAP program
Download iDoc XML to local drive

 

iDoc data downloaded in XML format to local drive using Z custom ABAP code
iDoc data downloaded in XML format

 

ABAP Code to download iDoc as XML:

The program was developed in SAP S4 HANA client, and it is compatible with newer SAP HANA versions. Copy the program code to a new executable Z ABAP program in transaction se38 to start using it.

2. Alternative method to download iDocs as XML.

If you do not want to create a new Z program in your system or you are not an ABAPer, you can configure a test partner profile using transaction we20 and configure an outbound profile with the desired message type/iDoc basic type. Assign a file port to the outbound partner profile configuration and reprocess the iDoc using transaction we19 or any other test tool. iDoc XML will be generated at SAP server location (al11) configured in file port.

iDoc XML downloaded to al11 location can be extracted to a local machine using transaction cg3z.

3. Download iDoc as Spreadsheet, HTML, text, etc.

If you want to download iDocs to other file formats such as Excel or html, there are several standard SAP options available.

  • Download iDoc using Transaction IDOC.

Using transaction iDoc and using option ‘Analyze iDoc Field values’ you can download iDoc data to multiple different formats.

Analyze iDoc field values in IDOC transaction
Analyze iDoc field values

 

But I was not able to convert the iDoc data to the external XML format.

download iDoc to different file formats
download iDoc to different file formats

 

  • Save iDoc as File using Transaction we02.

Using we02 you can also download iDoc to a local file.

Use we02 to download iDocs to excel, text, html and other formats
Use we02 to download iDocs

 

  • View XML format using Function Module IDOC_XML_TRANSFORM.

Go to transaction se37 and execute the FM IDOC_XML_TRANSFORM with iDoc number as input.

View iDoc XML format using Function Module IDOC_XML_TRANSFORM
View iDoc XML format using Function Module IDOC_XML_TRANSFORM

 

iDoc XML view using Function Module IDOC_XML_TRANSFORM
iDoc XML view using Function Module IDOC_XML_TRANSFORM

 

Check out my other posts on ALE/iDocs and please leave a comment if you have questions. Cheers!

Add a Comment

Your email address will not be published. Required fields are marked *