SAP ST TT ASSIGN

Get Example source ABAP code based on a different SAP table
  


ARTICLE

ST - tt:assign, Value Assignment

Syntax
<(><<)>tt:assign [to-ref='node'|to-var='variable']
[ref='node'|val='value'|var='variable'] />

Effect
You use the statement tt:assign to assign a value to a data root, a variable, or a parameter.
You use to-ref or to-var 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:
a node node specified in accordance with the addressing rules,
a variable or a parameter variable,
a value value specified in accordance with the rules for ABAP values (source field only)
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
During serialization, 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, then tt:assign has no effect during serialization.

Deserialization
During deserialization, 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, then tt:assign has no effect during deserialization.
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 tt:assign statements. During serialization, this statement has no effect.

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.