XSL and ABAP
I’ve seen some complaints lately that there isn’t enough about ABAP around here. Now my ABAP might be a little rusty but I can still remember a thing or two, so let’s start talking about it.
If you do care about ABAP its likely that you also care about moving data between systems. What you might not realize is that as of release 6.20 you can map external data in XML format to ABAP data structures using XSLT. From good old SE80 select the context menu from the root of your object tree and choose Create -> More… -> XSL Transform and you’ll get a dialog to Create XSL Program. This is where you should enter your xsl.
Well what would you put here? Well you are probably looking to map from an external xml schema to an internal data structure so type mappings would help. Look up the reference on ABAP data serialization at ifr.sap.com.
To apply your transform use CALL_TRANSFORMATION giving it the name of your XSL program, your xml source and a variable to hold the result. Such as:
NAME = var
Specifying XML after source indicates a transform into an ABAP data structure. XML before source would indicate that the result will be XML. NAME in this example is the element name that wraps the XML representation of the ABAP data in the XSL.
Now the above is omitting quite a bit of detail but hopefully gives you the idea that you can do this and some pointers to get started. Don’t forget to read the help files. Of course the real credit goes to a wonderful article on this topic, “From XML to ABAP Data Structures and Back” from the July/August 2002 issue of the SAP Professional Journal.