SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → Simple Transformations → ST - Structure of ST Programs →Simple Transformation, Example of an ST Program
Symmetrical serialization and deserialization of a nested structure.
Source Code
REPORT demo_st_program.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA(out) = cl_demo_output=>new(
)->begin_section( `Serialization` ).
DATA source1(10) TYPE c VALUE 'Field1'.
DATA source2(10) TYPE c VALUE 'Field2'.
CALL TRANSFORMATION demo_st_program
SOURCE root1 = source1
root2 = source2
RESULT XML DATA(xml).
out->write_xml( xml ).
out->next_section( `Deserialization` ).
DATA result1 LIKE source1.
DATA result2 LIKE source1.
CALL TRANSFORMATION demo_st_program
SOURCE XML xml
RESULT root1 = result1
root2 = result2.
out->write_data( result1
)->write_data( result2
)->display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
The called transformation DEMO_ST_PROGRAM shows the principal structure of an ST program:
A single template, tmpl1, is defined as the main template. Two data roots, ROOT1 and ROOT2, are declared. The template contains two subelements, X1 and X2 of an element X0, which are given the values of the data roots during serialization (or whose values are given to the data roots during deserialization) using the tt:value command. After the deserialization, result1 and result2 have the same content as source1 and source2.