element. I guess your code might look something like the following:
If you run this transformation you won't get the expected result. Why? Compared to XSLT, variables in ST behave like variables in any other procedural language and you can assign them for more than one time. But following two lines doesn't work:
First you want to read it into an ABAP structure and then bind it to a variable. Even changing the order of the two commands wouldn't help you. Let's test it with an easier example:
Here is the ABAP code for running this ST:
DATA xml_string TYPE string.
DATA field1 TYPE string.
DATA field2 TYPE string.
xml_string = ` Test `.
CALL TRANSFORMATION my_transformation
SOURCE XML xml_string
RESULT ROOT1 = field1
ROOT2 = field2.
You will verify that ROOT2 is empty afterwards, so this doesn't work. Therefore we have to find another solution to implement our transformation, perhaps using the condition construct. But here we have another problem; the template content of the conditional is either a template (then you can't do assignments to variables for example) or it is evaluated unconditionally during deserialization. So, in fact, I can't tell you whether this will lead to success.
Summary
So let's summarize what we have learned. Programming ST is not difficult and ST does a great job transforming an XML document into nested ABAP structures, back and forth, because it is designed for this task. So to be honest, it's not surprising that transformations to a relational model is impossible without heavy post processing because for this task we have to create a set of internal tables from an XML tree and have to add foreign keys. In our small example above those keys are not part of our model so we would have to generate them and, of course, break the symmetry of our transformation thereby. The impossibility is caused by the fact that we can't increment variables and we can't append deserialized data to an internal table.
If we want to describe the (lack of) power of Simple Transformations I suggest to collect some simple examples for transformations we can't realize with ST and reduce other problems to them.
But does the lack of expressiveness really bother you? I don't believe in solutions that can solve every problem without causing new problems. Perhaps some new features that could help us will be added to ST in post 6.40 development but designers will have to be careful not to make the language too complex.
On the other hand, a software developer should try to choose the right technology -- iXML, XSLT, XSLT with ABAP calls or Java enhancement, ST or even JAXB -- and not to misuse a certain technology to create programs that can solve a problem in an unexpected way but are hard to understand and possibly difficult to maintain.
Check back soon for part 2 of this series!
This content is reposted from the .
Copyright 2006, SAP Developer Network
SAP Developer Network (SDN) is an active online community where ABAP, Java, .NET, and other cutting-edge technologies converge to form. a resource and collaboration channel for SAP developers, consultants, integrators, and business analysts. SDN hosts a technical library, expert blogs, exclusive downloads and code samples, an extensive eLearning catalog, and active, moderated discussion forums. SDN membership is free.
Want to read more from this author? Click here to read Tobias Trapp's weblog. Click here to read more about ABAP on SDN.