Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML →  ST - Simple Transformations →  ST - Serialization and Deserialization →  ST - Value Assignments 

ST - tt:assign, Value Assignment

Other versions: 7.31 | 7.40 | 7.54

Syntax


<tt:assign [to-ref="node"|to-var="variable"] 
           [ref="node"|val="value"|var="variable"] />

Effect

The statement tt:assign is used to assign a value to a data root, a variable, or a parameter.

to-ref or to-var is used to specify the target field, and ref, val, or var to specify the source field. If no target field or no source field is specified, the current node is used implicitly. Target and source fields can be:

An assignment between reference variables with tt:assign is possible only if the static type of the source variables is more special or the same as the static type of the target variables (upcast). In all other cases, you can use the tt:cast statement to perform a downcast.

Serialization

In serializations, only variables (or parameters) are given the current value of the source field. If a data node is specified as the target field (using to-ref) or if the current node is specified implicitly, tt:assign is ignored in serializations.

Deserialization

In deserializations, only variables (or parameters) or directly specified values are evaluated as source fields. If a node is specified as the source field (using ref) or if the current node is specified implicitly, tt:assign is ignored in deserializations.

The following syntax can be used if the current node, or the node specified after to-ref, is an internal table:

<tt:assign [to-ref="itab"]>
  <tt:assign [to-ref="comp"]
             [val="value"|var="variable"] />
  ...
</tt:assign>

A row is then inserted into the internal table specified. The values of the components are set using the inner statements tt:assign. This statement is ignored in serializations.


Example

The transformation below shows value assignments:

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:variable name="VARI" val="11"/>
  <tt:parameter name="PARA" val="22"/>
  <tt:template>
    <tt:assign to-var="VARI" var="PARA"/>
    <tt:assign to-ref="ROOT" var="VARI"/>
  </tt:template>
</tt:transform>

During a deserialization, the value 22 is assigned to the ABAP data object bound to the data root ROOT.