Show TOC

Creating Transformations for XMLLocate this document in the navigation structure

You can create a simple transformation or an XSLT program to describe transformations between ABAP data and XML data.

Prerequisites

This functionality has been available since SAP NetWeaver 7.5 SP00.

Procedure

  1. In the Project Explorer, select the relevant package node.
  2. Open the context menu and choose Start of the navigation path New Next navigation step Source Code Library Next navigation step Transformation End of the navigation path to launch the creation wizard.
  3. Specify the Project and Package properties in the repository of the ABAP class to be created.
  4. Enter the Name and Description for the class to be created.
  5. Choose one of the following Templates:
    • XSLT program to convert an XML document to another XML document
    • Simple transformation to convert the ABAP objects structures and table types into XML data
  6. Choose Next.
  7. Assign a transport request.
  8. Start the creation with Finish.

Results

The back-end system creates an inactive version of a transformation on the basis of the selected template in the selected package. In the Project Explorer, the new transformation is added to the Source Library of the corresponding package node. In the source code editor, the initially generated XML source code is displayed and ready for editing.

Simple Transformation

If you have created a simple transformation, the following content is generated and added as source text:

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="ROOT"/>

<tt:template>
</tt:template>

</tt:transform>

Description of the Source Code Elements and Segments

Generated line Meaning

<?sap.transform simple?>

Generated during checking/activating, used for recognizing the source text type.

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

Top-level element for a Simple Transformation, with namespace declaration.

<tt:root name="ROOT"/>

Declaration of an ABAP root node. The name “ROOT” is only an example. Any number of root nodes (but at least one) can be declared here.

<tt:template>

Definition of the transformation

</tt:template>

Any number of additional (named) templates can be defined here for modularization purposes.

</tt:transform>

XSLT Transformation

If you have created a XSLT transformation, the following content is generated and added as source text:

<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sap="http://www.sap.com/sapxsl"
>

<xsl:strip-space elements="*"/>

<xsl:template match="/">
</xsl:template>

</xsl:transform>

Description of the Source Code Elements and Segments

Generated Line Meaning

<xsl:transform version="1.0"

Specifies the XSL version.Each XSLT program has to support Version 1.0.

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

Declares the namespace for the XSL standard. Each valid XSLT program has to support this standard.

xmlns:sap="http://www.sap.com/sapxsl"

Declares the SAP namespace extension needed for ABAP calls.

<xsl:strip-space elements="*"/>

Ensures that "whitespaces" (spaces, tabulator, return, and so on) are not considered in any of the elements of the document tree at runtime for the purpose of improving performance. This line is a proposal especially for representing data structures.

Insert your source text with global elements (such as parameters) here.

<xsl:template match="/">

Defines the beginning of the XSL templates and associates the template with the root of the XML document.

Define one or more templates with the relevant transformation rules here.

</xsl:template>

Defines the end of the XSL template.

</xsl:transform>

Defines the end of the XSLT program.