Skip to Content
Author's profile photo Former Member

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:
CALL TRANSFORMATION
  xslprogram
SOURCE XML
  xmlfile
RESULT
  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.

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Karsten Bohlmann
      Karsten Bohlmann
      Thanks for mentioning this topic. The implementation of ABAP/XML mappings via CALL TRANSFORMATION has indeed been an important development in our group during the past 3 years.

      Please note that the IFR link relates to earlier, weaker mechanisms (which use, however, a mostly similar XML format). The SDIXML* functions are outdated and should not be used in 6.** systems. Also, XRFC and the BC are unrelated to CALL TRANSFORMATION.

      The easiest way to find out how the XML representation of a particular data structure looks like is as follows: Populate the data structure with typical values and invoke the identity "id" (part of the basis delivery):
      CALL TRANSFORMATION id
        SOURCE     root = my_data_structure
        RESULT XML my_xml_string.
      The resulting XML document shows what source format your ABAP-to-XML XSLT program (to be used in place of "id") must expect, and what result format your XML-to-ABAP XSLT program must produce.

      As soon as we find time, we will provide more detail on this topic in SDN.

      Best regards,
      Karsten Bohlmann (SAP TechDev / XML technology)

      Author's profile photo Former Member
      Former Member
      Is there a way to fill an internal table as RESULT of CALL TRANSFORMATION or do I have to process the data row by row?

      Best regards,
      Stefan Schumacher

      Author's profile photo Karsten Bohlmann
      Karsten Bohlmann
      The SPJ article is now available in SDN:
      Article.
      It answers most questions on the XSLT/ABAP topic, including the previous one.
      Author's profile photo Former Member
      Former Member
      Will XSLT transformation handle creation of an internal table with deep structures in it (embedded occurs tables as fields in the structure) natively for deserialisation of XML coming in? I have successfully serialised a deep structure table from ABAP to XML but am having difficulty with the reverse. We want to send out deep structure forms that are returned to us with data in them and receive the XML replies into the same internal table structure that we sent out.

      Thanks,
      Mark Browne.

      Author's profile photo Karsten Bohlmann
      Karsten Bohlmann
      Of course deserialization of such a structure is possible too. Simply have a look at the result of "id" in ABAP-to-XML mode (applied to the ABAP structure containing sample values). If you produce this canonical-XML instance in XML-to-ABAP mode (either by "id" or by a "real" transformation), you fill the structure again.