Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Simple Transformations →  ST - Serialization and Deserialization →  ST - Reading and Writing Variables 

ST - tt:read, Read Variables

Other versions: 7.31 | 7.40 | 7.54

Syntax


<tt:read var="variable" [type="type" [length="len"] 
                                     [decimals="dec"]]
                        [map="..."]
                        [minLength|maxLength="len"]
                        [xsd-type...] />

Effect

The command tt:read enables you to read a value of the XML inbound stream into a variable or a parameter:

You use variable to specify the variable or a parameter into which the value is read. The same applies to the attributes map, minLength, and maxLength plus xsd-type as to the statement tt:value (however tt:read always ignores minLength).

The other attributes are used to specify the expected type. 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 value read must match the specified type and the value must be in the correct ABAP value range. Otherwise an exception is raised

Serialization

The tt:read command has no effect in serializations.

Deserialization

If no type conflict occurs, the variable or parameter is set to the value of the current position in the inbound stream (after map if applicable). Depending on the type of the variable or parameter, a mapping takes place in accordance with the asXML format.


Example

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 var="VARI" type="I" />
    </X>
    <tt:assign to-ref="ROOT" var="VARI"/>
  </tt:template>
</tt:transform>

If the XML fragment in question is <X>333</X>, then, after deserialization, the data object bound to the data root ROOT has the value 333 due to the assignment using tt:assign.