Show TOC

Syntax documentationStructures Locate this document in the navigation structure

The serialization and deserialization of structures results directly from the addressing rules, because the structures can be mapped directly to the tree structures that start from the data roots. When the current node is bound to an elementary component of an ABAP structure, the structure can be processed with tt:value just like an elementary data object.

Example

The three ST programs in the sections Current Node, Addressing the Current Node, and Addressing Subnodes of the Current Node can transform a nested ABAP structure symmetrically. The following program can call these three ST programs:

Syntax Syntax

  1. DATA: BEGIN OF struc1,
  2.         col1(10) TYPE c VALUE 'ABCDEFGHIJ',
  3.         col2     TYPE i VALUE 111,
  4.         BEGIN OF struc2,
  5.           col1 TYPE d VALUE '20040126',
  6.           col2 TYPE t VALUE '084000',
  7.         END OF struc2,
  8.       END OF struc1.
  9. DATA: xml_string TYPE string,
  10.       result LIKE struc1.
  11. TRY.
  12.     CALL TRANSFORMATION ...
  13.       SOURCE root = struc1
  14.       RESULT XML xml_string.
  15.     cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).
  16.     CALL TRANSFORMATION ...
  17.       SOURCE XML xml_string
  18.       RESULT root = result.
  19.     IF struc1 <> result.
  20.       MESSAGE 'Deserialization <> Serialization' TYPE 'I'.
  21.     ENDIF.
  22.   CATCH cx_st_error.
  23.   ...
  24. ENDTRY.
End of the code.

The result of the serialization is the same XML document for all three simple transformations:

Syntax Syntax

  1. <X>
  2.   <X1>ABCDEFGHIJ</X1>
  3.   <X2>111</X2>
  4.   <X3>
  5.     <X1>2004-01-26</X1>
  6.     <X2>08:40:00</X2>
  7.   </X3>
  8. </X>
End of the code.