Start of Content Area

Syntax documentation Reading an XML Value into a Variable  Locate the document in its SAP Library structure

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"] />

 

Use variable to specify the variable or a parameter into which to read the value. For the attribute map the same applies as with 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 under Elementary Data Objects and the value must lie in the corresponding ABAP value range (see ABAP keyword documentation), otherwise an exception is triggered.

 

Serialization

During serialization, the tt:read command has no effect.

 

Deserialization

If no type conflict exists, the variable (or parameter) is set to the value of the current position in the inbound stream, if applicable after the mapping_list.

 

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 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 the deserialization the data object bound to the data root ROOT has the value 333 due to the assignment with tt:assign.

 

 

 

 

End of Content Area