In a standard course of development, extracting an XML into SAP is not ideal. Most of the interfaces involve PI which is more adept and accurate in handling XML files and pass the data in a structure. On the other hand in the case of SAP, the file is pulled into the system and then converted into an internal table.

This can be achieved using two FMs with following steps –

  1. Get the file into XSTRING format using OPEN DATASET
  2. Use FM SRTUTIL_CONVERT_XML_TO_TABLE or SMUM_XML_PARSE. Data will be pulled into an internal table.

The steps after this involve parsing the content of XML by checking each tag and hierarchy/level and use the data accordingly. Each value in a tag-hierarchy will either be a relevant value or define a value in a tag following it. It will be important to be cognizant of that flow while writing the logic.

Example: Level 8 – tag ‘Address’ – value ‘Correspondence’ might not mean anything but it will explain that in level 9 – tag ‘Address1’ – value ‘ABC Lane’ refers to correspondence address, not permanent address or office address.

~S