Reading an XML Value into a
Variable
The command tt:read enables you to read a value of the XML inbound stream into a variable or a parameter:
<tt:read
var="variable" type="type"
[length="len"]
[decimals="dec"]
[map="mapping_list"]
[maxLength="length"] />
Use variable to specify the variable or a parameter into which the value is read. The same conditions apply to the attributes map and maxLength as to the tt:value statement.
The other attributes are used to specify the expected text. In statement tt:read, only elementary ABAP types can be specified, which can partly be generic. The syntax of this is the same as for statement tt:type.
The read-in value must correspond to the type specification according to the table in Elementary Data Objects and the value must lie in the corresponding ABAP value range (see ABAP keyword documentation); otherwise an exception is raised.
The tt:read command has no effect in serializations.
If no type conflict occurs, the variable (or parameter) is set to the value of the current position in the inbound stream, if applicable after the mapping_list. Appropriate mapping rules apply, depending on the type of the variable (of the parameter).
Deserialization of a value into a variable.
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root
name="ROOT"/>
<tt:variable
name="VARI"/>
<tt:template>
<X>
<tt:read type="I" var="VARI"/>
</X>
<tt:assign
to-ref="ROOT" var="VARI"/>
</tt:template>
</tt:transform>
If the read-in XML fragment is <X>333</X>, then, after deserialization, the data object bound to the data root ROOT has the value 333 due to the assignment with tt:assign.