Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML →  XSL Transformations →  Identity Transformation 

Identity Transformation to asXML Format

This example demonstrates the serialization of ABAP data to the asXML format.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    TYPES oref  TYPE REF TO object.
    DATA: dref1 TYPE REF TO oref,
          date  TYPE d,
          time  TYPE t,
          dref2 LIKE dref1.

    dref1    = NEW #( ).
    dref1->* = NEW c2( ).

                        SOURCE xmldat = sy-datum
                               xmltim = sy-uzeit
                               ref  = dref1
                        RESULT XML DATA(xmlstr).
    EXPORT obj = xmlstr TO DATABASE demo_indx_blob(xm)
                        ID 'OBJECT'.

    cl_demo_output=>display_xml( xmlstr ).

    IMPORT obj = xmlstr FROM DATABASE demo_indx_blob(xm) ID 'OBJECT'.
                        SOURCE XML xmlstr
                        RESULT xmldat = date
                               xmltim = time
                               ref = dref2.


Serialization of Data Objects to a String xmlstr Using the Identical Transformation ID A date field date, a time field time, and a data reference variable dref1 are serialized. The data reference variable points to an anonymous object reference variable, which in turn points to an object of the class c2. Objects serialized in this way can be stored persistently, for example in a data cluster. After the objects are imported from where they are stored, they are deserialized to further data objects. Following deserialization, dref2 points to another anonymous reference variable, such as dref1. This anonymous data object and the instance of the class c2 to which it points are created in deserializations.

The XML document created in the serialization is in asXML format. It is displayed in a browser and has approximately the content described below. In this description, line breaks and indents have been added. The element values contains the asXML representations of the three passed data objects. In the names X-MLDAT and X-MLTIM, "xml" is replaced by "X-ML". The attribute href of the element REF uses the key "d1" to refer to the representation of the associated anonymous data object in the element heap. This uses the key "o3" to refer to the representation of the instance of the class c2, which is also in the element heap. This representation is divided into the object parts for the classes c1 and c2. The object part for c1 contains the representation of the double-row structured internal table carriers. The object part for c2 contains the representation for the output parameter count of the method SERIALIZE_HELPER.

<?xml version="1.0" encoding="iso-8859-1" ?>
<asx:abap xmlns:asx="" version="1.0">
    <REF href="#d1" />
    <abap:refObject href="#o3" id="d1" />
            <CARRNAME>American Airlines</CARRNAME>
            <CARRNAME>Air Berlin</CARRNAME>

For further executable examples, see asXML, Examples of Mappings