Skip to Content

Simple Transformation

Simple Transformations are SAP programs which are used to convert ABAP data to XML and XML to ABAP data.They are like any other ABAP program and are managed through transport organizer.

Creating a Simple transformation

     Simple transformations can be created with SE80 – ABAP Development workbench tcode.  Select package and the right click on the transformation in the available objects list Name. Click on Create option.

/wp-content/uploads/2013/06/pic1_236120.png

  Upon clicking, the creation dialog box appears as below. Enter the required information and press ok to create the Simple Transformation.

/wp-content/uploads/2013/06/pic2_236121.png

How to call a simple transformation in our custom program

  They are defined with the key word – TRANSFORMATION in ABAP environment and can be called by the below statement,

 

Call
Transformation Z_TEST_STRANS42

             Source      yyyy

             Result      zzzz.

Scenario Explaining more about simple transformation

         The following scenario will give an idea about conversion of XML data into ABAP data, which is further written as an report output.

Say the XML input to the transformation would be as like below.

/wp-content/uploads/2013/06/pic3_236122.png

As shown below, we can use the transformation in our report program to convert XML data to ABAP data. The simple transformation Z_TEST_STRANS42, with below coding is applicable to do the above said functionality.

/wp-content/uploads/2013/06/pic4_236123.png

Inside the transformation, the template is mapped to the header tag and the line item details are read sequentially into the respective fields of the internal table. In our example, it is <teamMember> which is holding the line item details. 

/wp-content/uploads/2013/06/pic5_236124.png

Input XML File to the transformation:

/wp-content/uploads/2013/06/pic6_236125.png

We can view how the transformation works in debugger mode via the transaction XSLT.

  

For our example, Lets execute our transformation on debugger mode in XSLT transaction.

As said earlier, first the template name as specified in the transformation coding is mapped with the incoming XML string. In our example it is ‘teamMember’.

/wp-content/uploads/2013/06/pic7_236126.png

/wp-content/uploads/2013/06/pic8_236127.png

Next, it prepares to read the first tag value inside the template. In our case it is ’Name’ tag.

/wp-content/uploads/2013/06/pic9_236128.png

/wp-content/uploads/2013/06/pic10_236129.png

Likewise, it completes reading all the tag values and populates them in the corresponding fields of the internal table GT_PROFILE.

/wp-content/uploads/2013/06/pic11_236130.png

  

Upon execution of the transformation, the results are mapped into the internal table fields as shown below.

/wp-content/uploads/2013/06/pic12_236133.png

Below is the output of the report, as written from the internal table.

/wp-content/uploads/2013/06/pic13_236135.png

 

Reference:

 

http://help.sap.com/saphelp_nw04s/helpdata/en/e3/7d4719ca581441b6841f1054ff1326/frameset.htm

http://help.sap.com/erp2005_ehp_04/helpdata/en/fd/9d734b389211d596a200a0c94260a5/frameset.htm

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Joel Pena

    Hello Booma Ganesan

    Maybe you can help.

    I’m writing a transformation to create a XML file.
    it should look like:


    <ns0:root  xmlns:ns0=http://example.com>

         <ns0:leaf xmlns:ns0=http://example.com versión=”1.0”>

                                   …

          </ns0:leaf>

    </ns0:root>

    But after the transformation, SAP erases the second xmlns definition. The resulting code is:


    <ns0:root  xmlns:ns0=http://example.com>

         <ns0:leaf versión=”1.0”>

                                   …

         </ns0:leaf>

    </ns0:root>

    I need the xmlns listed on the leaf too. Did you know any solution?


    Regards,

    Christian

    (0) 

Leave a Reply