Skip to Content
Author's profile photo Girish Kumar Vedurupaka

Step by step procedure to process complex XML having deep structure(Header/Line Items) to internal table using CALL TRANSFORMATION

Requirement: An XML file contains header and line item details. We need to parse the XML and finally move the data to the internal table in ABAP.

Step 1: We need to analyse the XML file and create the structures accordingly using SE11.

Our XML looks as below.

Step 2: Create Structures in SE11 as per the above hierarchy.

Header Structure:


Line Item Structure


Create a table type for the Line Item structure


Final Structure:

Create a final structure with the header structure and line Item table types as shown below.

Step 3: Go to XSLT_TOOL transaction and create the transformation as shown below.


Step 4: A popup appears, enter the description and give the transformation type as Simple Transformation.


Step 5:  Click on the magic wizard icon.

Step 6: Right click on the ROOT and Insert new root. Enter the Root-Name and Type Name as Final structure name we have created in SE11. I.e zpipenomincreate.

Step 7: Below hierarchy will be created automatically.

Step 8: Drag the root node to the Simple transformation on the right-hand side.


Step 9: Save, go back and click on the source code tab.

All the bindings will be automatically created.


Step 10: All the Tags will be created in Upper case by default. As our original XML file tags contain both upper and lowercase tags we need to modify the above code which should be similar to theOur original  XML File .
* Note : XML File is attached to this blog.

For Example our XSLT tag looks in upper case compared to original XML


XML Tag: <PipelineNominationCreate>

we need to modify the XLST tags similar to original xml tags.

<?sap.transform simple?>
<tt:transform xmlns:tt=”” xmlns:ddic=”” xmlns:def=””>
<tt:root name=”ROOT” type=”?”/>
<LineItemNumber tt:value-ref=”LINEITEMNUMBER”/>
<Quantity tt:value-ref=”QUANTITY”/>
<UnitOfMeasureCode tt:value-ref=”UNITOFMEASURECODE”/>
<ConfirmationDateTime tt:value-ref=”CONFIRMATIONDATETIME”/>
<ConfirmationStatusCode tt:value-ref=”CONFIRMATIONSTATUSCODE”/>


Step 11: Save and activate the transformation.

Step 12: We need to create a report to get the XML data into the internal table.

REPORT z_xml_to_itab.


*Input file with path as constant
CONSTANTS gs_file TYPE string VALUE ‘C:\Users\girishv\Desktop\test.xml’.

* Table for storing the XML content from file
DATA: gt_itab         TYPE STANDARD TABLE OF char2048,
gs_create_nomin TYPE           zpipenomincreate,
gt_create_nomin TYPE  TABLE OF zpipenomincreate,
lv_msg         TYPE string,
lv_header      TYPE string,
lv_item      TYPE string,
r_excep         TYPE REF TO cx_st_match_element .

* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
filename                = gs_file
data_tab                = gt_itab
file_open_error         = 1
file_read_error         = 2
no_batch                = 3
gui_refuse_filetransfer = 4
invalid_type            = 5
no_authority            = 6
unknown_error           = 7
bad_data_format         = 8
header_not_allowed      = 9
separator_not_allowed   = 10
header_too_long         = 11
unknown_dp_error        = 12
access_denied           = 13
dp_out_of_memory        = 14
disk_full               = 15
dp_timeout              = 16
not_supported_by_gui    = 17
error_no_gui            = 18
OTHERS                  = 19.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

* Perform the XSLT stylesheet
*— Data in the excel will be collected in gs_create_main.
SOURCE XML gt_itab
RESULT pipelinenominationcreate = gs_create_nomin.
APPEND gs_create_nomin to gt_create_nomin.
CLEAR gs_create_nomin.
CATCH cx_st_match_element INTO r_excep.
lv_msg = r_excep->get_text( ).
WRITE lv_msg.

LOOP AT gt_create_nomin INTO gs_create_nomin.
* Header
WRITE : ‘Header’. NEW-LINE.
CONCATENATE gs_create_nomin-pipelinenominationcreateheader-PIPELINECYCLE
gs_create_nomin-pipelinenominationcreateheader-DESCRIPTION INTO lv_header SEPARATED BY space.
WRITE : / lv_header.

lt_lines = gs_create_nomin-pipelinenominationcreatedetail.

WRITE ‘Line Items’.
LOOP AT lt_lines INTO ls_lines.

WRITE / lv_item.

Step 13: Execute the Report.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Girish,


      I don't find the file XML in this page. Can you say where I obtain this file?

      Thank you.

      Author's profile photo Amrit Kumar Singh
      Amrit Kumar Singh

      Instead of Local XML file can it be done for web XML file. Fetching data from web XML file using the links.

      Author's profile photo Tamit Kumar Das Sharma
      Tamit Kumar Das Sharma

      Hello Girish Kumar Vedurupaka,

      Very nice article. Could you provide some details on creating a transformation of category standard?


      Author's profile photo B.Sanjeev Naidu
      B.Sanjeev Naidu

      Hello Girish Kumar Vedurupaka,

      is it possible to make optional tag <PipelineNominationCreateHeader> ?


      example: Simple%20transformation

      Simple transformation

      Author's profile photo Friederike Braun
      Friederike Braun

      Hello Girish Kumar Vedurupaka ,

      thank you for this nice tutorial - it worked fine, except in our XML the header looks like this:

      <?xml version="1.0" encoding="utf-8"?>

      The "UTF-8" should be in capital letters -> do you know where to change this?