Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Simple Transformations →  ST - Serialization and Deserialization →  ST - Transformation of ABAP Values 

ST - tt:copy, asXML Format

Other versions: 7.31 | 7.40 | 7.54

Syntax


<tt:copy [ref="node"] />

Effect

Command tt:copy is used to serialize in and deserialize from the asXML format. It can be used on all data objects with the exceptionof reference variables or objects containing reference variables as components.

The optional attribute ref can be used to define the current node for the command. If ref is not specified, the current node of the surrounding element is used.

Serialization

During the serialization process, the entire ABAP data object that is bound to the current node, along with all its components, is recursively transformed to asXML format and used in the XML document in place of the command.

Deserialization

During the deserialization process, the XML data stream is interpreted as asXML format and its values are passed on to the ABAP data object that is bound to the current node.


Note

During the serialization of data objects using tt:copy, it is important to note that a node will not be automatically inserted for the asXML format created. In order to obtain a valid XML document, the node must be explicitly specified in the template. Otherwise the XML document cannot be deserialized. The only exceptions are structures with a single component or internal tables with a single row. However, these do not generally have any practical use.


Example

The following simple transformation serializes the ABAP data object that is bound to data root ROOT under the node <node> into the asXML format. Without the specification of the node <node>, the transformation would not result in a valid XML document and deserialization would cause an exception.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <node>
      <tt:copy  ref="ROOT" />
    </node>
  </tt:template>
</tt:transform>

When the ABAP program from the example in section Internal Tables calls this transformation, the serialization process has the following result:

<node>
  <item>
    <KEY>2</KEY>
    <VALUES>
      <item>4</item>
      <item>8</item>
      <item>16</item>
    </VALUES>
  </item>
  <item>
    <KEY>3</KEY>
    <VALUES>
      <item>9</item>
      <item>27</item>
      <item>81</item>
    </VALUES>
  </item>
  <item>
    <KEY>4</KEY>
    <VALUES>
      <item>16</item>
      <item>64</item>
      <item>256</item>
    </VALUES>
  </item>
</node>

The Simple Transformation is symmetrical.