ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → ST - 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 exception of 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
In serializations, 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 data in place of the command.
Deserialization
In deserializations, the XML data stream is interpreted as asXML format and its values are passed to the ABAP data object that is bound to the current node.
Note
In serializations of data objects using tt:copy, it is important to note that a node will not be automatically inserted for the asXML format created. To get valid XML data, the node must be explicitly specified in the template. If not, the XML data 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. If the node <node> is not specified, the transformation would not produce valid XML data and deserialization would raise an exception.
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:
<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.