This weblog series is about XML processing in ABAP, especially Simple Transformations. In Part one I claimed  that we can’t use Simple Transformations to transform nested hierarchical data into a relational data  model. In fact I was wrong at least from a theoretical point of view. Here I want to present a kind of solution. In fact this is only a proof-of-concept. I don’t recommend it as a best practice.

Advanced Simple Transformations

Let’s get into detail. We have a list of  elements and each has a text content and a nested list of  elements that have only text content. We want to write the text content of the  elements into a data root and the content of the its  child elements into another. Then we want to calculate a foreign key that links the  elements to their parents. Let me present a small ABAP Programm that defines the data structures and calls the transformation:

In fact all we need to solve this task is written down in my following weblogs: Part two and three. Here is the ST program:

Let me explain how it works. We define a sub template that increments a variable by  doing a case distinction. Because tt:loop can’t append to internal tables we use tt:assign and work a multiple XML elements using tt:group. We store the text content into variables using tt:read and store the numbers in variables counter1 and counter2, too.

After calling the program we get the expected result in l_tab_root1:

1 L
2 M
3 G

This is the content of l_tab_root2:

2 1 h
2 2 w
3 1 y
3 2 x
3 3 z


  • This solution isn’t symmetric and works for deserialization and not for serialization.
  • It only works for a constant number of occurrences of elements in the input stream.
  • I don’t assume it will be fast if we adapt it for huge datasets.

We can learn that an increment operator is very powerful and offers a new range of applications. True numerical  operations instead of the humble solution above could be a benefit to Simple Transformations although we have to be careful: In my opinion the best ST programs are the symmetric ones.

New NetWeaver Information at

Very Helpfull



User Rating: Be the first one !