ABAP - Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML → 

CALL TRANSFORMATION

Quick Reference

Syntax

CALL TRANSFORMATION ID
                  | trans|(name)
                    [PARAMETERS {p1 = e1 p2 = e2 ...}|(ptab)]
                    [transformation_options]
                    SOURCE {XML src_xml}
                         | {{bn1 = e1 bn2 = e2 ...}|(stab)}

                    RESULT {XML rslt_xml}
                         | { {bn1 = f1 bn2 = f2 ...}|(rtab) }.


Alternatives:


1. ... ID ...



2. ... trans|(name) ...




Additions


1a. ... SOURCE {XML src_xml}|{{bn1 = e1 bn2 = e2 ...}|(stab)}



1b. ... RESULT {XML rslt_xml}|{{bn1 = f1 bn2 = f2 ...}|(rtab)}



2. ... PARAMETERS {{p1 = e1 p2 = e2 ...}|(ptab)}


Effect

This statement calls the specified XSL transformation (XSLT) or a simple transformation (ST). The source of the transformation is specified behind SOURCE and the result is stored behind RESULT. PARAMETERS can be used to pass parameters to the transformation. transformation_options can be used to specify transformation options. The possible transformation types are:

JSON-XML, which maps JSON data to XML, can be used to execute all categories of transformations for JSON that are also possible for XML. More information is available in Transformations for JSON.

Notes

The library used also determines the character set that is supported. The iXML Library supports UCS-2; the sXML Library supports UTF.

Example

The transaction STDEMO demonstrates various transformations from ABAP data to XML and JSON.

Alternative 1

... ID ...


Effect

Specifies the identity transformation ID directly. This transformation exists as an XSL transformation in the repository, but is executed by the runtime environment in an optimized ID engine, depending on the transformation source or target. For more information, see:

Example

Example of an identity transformation

Alternative 2

... trans|(name) ...


Effect

Specifies any transformation. The transformation addition can be specified either statically or dynamically:

If static, the transformation is specified directly as trans.
If dynamic, the transformation is specified as the uppercase content of a parenthesized character-like data object name.

The specified transformation must exist as an XSLT program or as a simple transformation in the repository. If a dynamically specified transformation is not found, an exception of the class CX_INVALID_TRANSFORMATION is raised.

Example

Example of a simple transformation

Addition 1a

... SOURCE {XML src_xml}|{{bn1 = e1 bn2 = e2 ... }|(stab)}

Effect

Specifying the source.

Transformation of XML data

When XML src_xml is specified, the XML data in src_xml is transformed. src_xml can exist in the following forms:

Notes

Transformation of ABAP data

bn1 = e1 ... or (stab) is used to specify the ABAP data e1 e2 ... that is to be transformed.

Instead of using a static parameter list, the data objects can be passed dynamically as value pairs in the columns of an internal table stab that has the type ABAP_TRANS_SRCBIND_TAB from the type group ABAP.

Serializations convert the elementary components of the ABAP data objects to asXML or asJSON, in accordance with the mappings for predefined ABAP types or for further XML schema data types. This can raise the exceptions described there, some of which can be bypassed by using transformation options.

The case of the names in the XML or JSON data depends on how they are specified in the ABAP runtime environment. If specified statically (b1, b2, ...), uppercase is used; if specified dynamically in stab, the case used there is used.

Note

When a simple transformation is called, the serialization always creates an internal XML writer object, which can be addressed using the interface IF_SXML_WRITER from sXML Library. The object is accessed using attributes of the ST statement tt:call-method.

Example

For an overview of all possible XML sources, see XML Sources of Transformations.

Example

For a deserialization of ABAP data from an XML reader from sXML Library, see sXML Library, Transformation from XML Reader.

Addition 1b

... RESULT {XML rslt_xml}|{{bn1 = f1 bn2 = f2 ...}|(rtab)}

Effect

Specifying the target.

Transformation to XML data

When XML rslt_xml is specified, a transformation to XML data takes place and this data is passed to rslt_xml. rslt_xml can exist in the following forms:

Notes

Security Note

If the output method "html" of an XSL transformation is used to create HTML data that contains JavaScript parts, the syntax characters <, >, &, ", and ' in the JavaScript parts are not transformed to their XML notation. To prevent cross site scripting (XSS) in HTML data that contains dynamic JavaScript parts, appropriate measures must be taken. These measures are best applied in the XSL transformation that creates the data.

Transformation to ABAP data

Use bn1 = f1 ... or (rtab) to specify the ABAP target fields f1 f2 ... into which the XML data is to be transformed.

Instead of using a static parameter list, the data objects can be passed dynamically as value pairs to the columns of the internal table rtab that has the type ABAP_TRANS_RESBIND_TAB from the type group ABAP.

Deserialization converts the elementary XML or JSON values to elementary ABAP data types in accordance with the mappings for predefined ABAP types or for further XML schema data types. This can raise the exceptions described there, some of which can be bypassed by using transformation options.

The case used in the XML or JSON data must match exactly the case specified in the ABAP runtime environment. If specified statically (b1, b2, ...), uppercase is used; if specified dynamically in rtab, the case used there is used.

When deserializing from a canonical display format, if no corresponding asXML element or asJON object component exists for an ABAP object, the data object retains its previous value. If an empty XML element or an empty JSON array is assigned to an elementary or tabular ABAP data object, the ABAP data object is set to its type-friendly initial value. If an empty XML element or empty JSON object is assigned to a structure, this has the same effect as non-existent elements on the structure components. The structure components retain their previous values. The transformation option clear with the value "all" can be used to initialize all data objects that have nonexistent or empty elements assigned to them.

In the case of the deserialization of internal tables with non-unique table keys, the order of the duplicate rows in relation to these keys is not retained.

Note

When a simple transformation is called, the deserialization always creates an internal XML reader object, which can be addressed using the interface IF_SXML_READER from sXML Library. The object is accessed using attributes of the ST statement tt:call-method.

Example

For an overview of all possible XML targets, see XML Targets of Transformations.

Example

More information about the transformation of XML data to DOM representation in iXML Library is available in iXML Library, DOM Representation.

Example

For a transformation of ABAP data to an XML writer from sXML Library, see sXML Library, Transformation to XML Writer.

Example

More information about how to deserialize missing or empty asXML elements or asJSON object components is available in:

Example

For information about transforming syntax characters in XML targets is available in Transformation of Syntax Characters.

Addition 2

... PARAMETERS {{p1 = e1 p2 = e2 ...}|(ptab)}

Effect

This addition can be used to bind ABAP data objects e1 e2 ... to the parameters p1 p2 ... of an XSL transformation or a simple transformation. All elementary data objects and object references are permitted.

Instead of using a static parameter list, the parameters can be specified dynamically as value pairs in the columns of the internal table ptab that has one of the following types from the type group ABAP:

Passing Parameters to XSL Transformations

The specified parameters must be defined in an XSL transformation as input parameters, as follows:

<xsl:param name="..." sap:type="..." />

Specify the parameter name for the attribute name in uppercase letters. Before a binding can take place, the case used in the XML document must match exactly the case specified in the ABAP runtime environment. If specified statically (b1, b2, ...), uppercase is used; if specified dynamically in rtab, the case used there is used.

For the optional attribute type, one of the type names string, number, boolean, nodeset, xstring, or object(...) can be defined, with a global ABAP class specified in parentheses behind object. The namespace before type must be defined as xmlns:sap="http://www.sap.com/sapxsl", with the prefix sap proposed as a convention.

If no type is specified in the transformation, the data types of elementary parameters are mapped to XSL types in accordance with the following table.

ABAP Data Type XSL Parameter Type
c, d, n, string string
i (b, s), f, p number
x, xstring string, where the content is represented in Base 64.

If the XSL types shown in the table above are specified explicitly in the XSL transformation, appropriate elementary ABAP parameters must be specified that can be converted to the XSL type:

If a parameter does not match the XSL type, a non-handleable exception is raised. If a parameter defined in the XSL transformation is not passed, it is set to a default value in the transformation. A specified parameter that is not defined in the XSL transformation is ignored.

Notes

Passing Parameters to ST Programs

In an ST program, the parameters must be defined as follows as parameters of the main template outside a template:

<tt:parameter name="..." [kind="..."]
                         [[s-val="..."][d-val="..."]]|[val="..."] />

When an ST program is called, output parameters and input/output parameters are supported as well as input parameters. The type of the parameter is defined using kind in the ST program, where "in", "out", and "inout" can be specified. "inout" is the default. The val attributes can be used to define replacement values.

Exceptions

Handleable Exceptions

CX_TRANSFORMATION_ERROR

Subclasses of CX_ST_ERROR

CX_ST_CALL_ERROR

CX_ST_CALL_METHOD_ERROR

CX_ST_CONDITION

CX_ST_CONSTRAINT_ERROR

CX_ST_DESERIALIZATION_ERROR

CX_ST_FORMAT_ERROR

CX_ST_INVALID_XML

CX_ST_MATCH

CX_ST_REF_ACCESS

CX_ST_RUNTIME_ERROR

CX_ST_SERIALIZATION_ERROR

CX_ST_VALIDATION_ERROR

Subclasses of CX_XSLT_EXCEPTION

CX_XSLT_ABAP_CALL_ERROR

CX_XSLT_DESERIALIZATION_ERROR

CX_XSLT_FORMAT_ERROR

CX_XSLT_RUNTIME_ERROR

CX_XSLT_SERIALIZATION_ERROR



Continue
CALL TRANSFORMATION - transformation_options
CALL TRANSFORMATION - Examples