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.
Upon clicking, the creation dialog box appears as below. Enter the required information and press ok to create the Simple Transformation.
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.
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.
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.
Input XML File to the transformation:
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’.
Next, it prepares to read the first tag value inside the template. In our case it is ’Name’ tag.
Likewise, it completes reading all the tag values and populates them in the corresponding fields of the internal table GT_PROFILE.
Upon execution of the transformation, the results are mapped into the internal table fields as shown below.
Below is the output of the report, as written from the internal table.
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
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