Show TOC

Syntax documentationDefining the Transformation Direction Locate this document in the navigation structure

You can use the following ST commands to limit parts of templates for execution during serialization or deserialization:

Syntax Syntax

  1. <tt:serialize>
  2.   ...
  3. </tt:serialize>
  4. <tt:deserialize>
  5.   ...
  6. </tt:deserialize>
End of the code.

All the template elements listed within the tt:serialize element are only considered during serialization. All the template elements listed within the tt:deserialize element are only considered during deserialization.

Example

The following Simple Transformation serializes a structure and deserializes to an internal table:

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT1"/>
  3.   <tt:root name="ROOT2"/>
  4.   <tt:template>
  5.     <X>
  6.       <tt:serialize>
  7.         <Y>
  8.           <tt:value ref=".ROOT1.COL1" />
  9.         </Y>
  10.         <Y>
  11.           <tt:value ref=".ROOT1.COL2" />
  12.         </Y>
  13.         <Y>
  14.           <tt:value ref=".ROOT1.COL3" />
  15.         </Y>
  16.       </tt:serialize>
  17.       <tt:deserialize>
  18.         <tt:loop ref=".ROOT2">
  19.           <Y>
  20.             <tt:value />
  21.           </Y>
  22.         </tt:loop>
  23.       </tt:deserialize>
  24.     </X>
  25.   </tt:template>
  26. </tt:transform>
End of the code.

The following ABAP program can call the transformation:

Syntax Syntax

  1. DATA xml_string TYPE string.
  2. DATA: BEGIN OF struc,
  3.         col1 TYPE i VALUE 1,
  4.         col2 TYPE i VALUE 2,
  5.         col3 TYPE i VALUE 3,
  6.       END OF struc.
  7. DATA itab TYPE TABLE OF i.
  8. CALL TRANSFORMATION ...
  9.   SOURCE root1 = struc
  10.   RESULT XML xml_string.
  11. CALL TRANSFORMATION ...
  12.   SOURCE XML xml_string
  13.   RESULT root2 = itab.
End of the code.

After deserialization, the internal table contains three rows with the values of the structure components.