
Create the Simple Transformation
As we are ready with creating ABAP Dictionary objects, let’s move on, and open the transaction, called STRANS to create the Simple Transformation that will parse the content of the XML document into the internal format of the SAP. In the Transformation Editor, first let’s give a name to our transformation like ZCUSTOMER_ST, and hit the Create button.

On the follow up screen, we have to give a Short Description and choose a transformation type that is going to be Simple Transformation in our case. At last let’s apply the settings.

Implement the transformation logic
As you can see in the source code editor, the system generates an initial source code by default. We can implement the transformation logic in two different ways: manually editing the source code, or using the visual editor. Now, I want to show you the easier one, the visual editor that we can reach by pushing the “magic wand” button.

We can see the same information on this screen, except it displays the source code visually. First of all, we are going to delete the default root node by right clicking on the node ROOT, then choosing the option Delete root, because we want to use a different root.

Now, let’s right click on the empty, highlighted area, and choose the option Insert new root.

On the pop-up screen, we are going to set the Root-Name to the same root as we have in the XML document, CUSTOMERS, and then use the previously created ZCUSTOMER_TT table type in the Type-Name field. It means that we are going to send back the parsed data to the caller program in an internal table that has the type ZCUSTOMER_TT. At last, let’s apply the settings.

As a result, the system looks up for the structure of the specified table type, and inserts its elements as a group of nodes in a hierarchical view. Here, we want to copy these meta-data to render the same hierarchy on the Simple Transformation side that we can accomplish right clicking on the root node CUSTOMERS, and then choosing the option Mark data object.

Next, we are going to use this meta-data and generate the Simple Transformation also by right clicking on the empty, highlighted area, and choosing the option Insert marked type.

As you can see, we got almost the same structure. On the left hand side we defined the result structure, and on the right hand side we defined the simple transformation that has to correspond to the structure of the XML document.

Here, I found a problem, namely in the XML document we have a node like <CUSTOMER> </CUSTOMER>, but in the Simple Transformation we use ZCUSTOMER_STR. In order to have a properly functioning transformation, we have to change the name of this node by double clicking on it, and changing its name above to CUSTOMER. Using this feature, we can rename any simple transformation node if we need.

By hitting Enter, we can apply the rename on the marked node. As we are ready, let's activate the transformation, and hit the Back button to check the generated source code.

Editing the source code
As a result, we got the following code in the source editor:
We are very close to finish our first Simple Transformation, but I found one thing that we have to solve. As you could see in the source code, we are going to require a MANDT tag, but there is no MANDT tag in the XML document, since it only exist in SAP systems. To solve this problem, we have to make the MANDT tag optional in the Simple Transformation source code by using the conditional tag. Using conditional tags we can create more complex conditions to fulfill other business logic as well. That's it! That's the final simple transformation source code:
Summary
We have defined a result structure that has the type ZCUSTOMER_TT, so our simple transformation will send back the parsed data in this format that actually is going to be an internal table. After this, we used this structure and generated a simple transformation logic.
As a result, when we will execute this simple transformation, then it will go through on the content of the given XML document, and first looks for root node, called CUSTOMERS:
Then, it will loop through on it, and looks for child nodes that has the name, CUSTOMER.
In each iteration, it will ignore the tag MANDT, and save the content of the CUSTOMER_ID, FIRST_NAME, LAST_NAME, and so on into the corresponding fields that is specified in the tt:value-ref attribute that is actually the part of the result internal table. Each lines below actually represent a context mapping between the XML tags and the result structure.
Next, we are going to work on the Framework program that will execute our simple transformation.
Table of Contents