Convert IDOC to XML format with Full ABAP Code

Convert IDoc: This sample code will Convert idoc to XML file having the same schema as the IDoc.
NB: IDoc Schema can be generated by the tcode WE60 as following

WE60 - IDoc XML Schéma

Steps Convert Idoc To XML

Retrieve list of Idocs ( Table EDIDC )

For each Idoc

  • Build XML Filename -> : [Path] \ [Idoc_Nb] [.xml]
  • Check if file exists: if the document already exists, Skip this SAP Idoc

This standard method check if a local file exist

Create IDoc object using the cl_idoc_xml1 class

Extract Idocs Data as String

Download IDoc data as XML file

The complete ABAP program to Download IDoc in XML

Find also an other SAP Scn Wiki how to convert SAP IDoc to XML file.


Hi. I have been working as SAP Technical and functional for a decade. Through this blog, I am trying to share with you my experience. Hopefull, it makes your ways easier path ...Sab