ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML →  asXML - Canonical XML Representation →  asXML, Examples of Mappings → 

asXML, Mapping of Objects

The example demonstrates the mapping of referenced objects.

Source Code

REPORT demo_asxml_object.

CLASS serializable DEFINITION.
  PUBLIC SECTION.
    INTERFACES if_serializable_object.
    DATA attr TYPE string VALUE `Attribute`.
ENDCLASS.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA: oref TYPE REF TO serializable,
          xmlstr TYPE xstring.

    CREATE OBJECT oref.

    CALL TRANSFORMATION id
                        SOURCE object = oref
                        RESULT XML xmlstr.

    cl_demo_output=>display_xml( xmlstr ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

Description

The attributes of the object referenced by oref are displayed on subelements of the heap element. The connection between the reference variables in the values element and the object in heap takes place using an XML reference mechanism.