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 - Reading and Writing Variables 

ST - tt:read-write, Read or Write Variables

Other versions: 7.31 | 7.40 | 7.54

Syntax


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

Effect

The command tt:read-write is a short form of the following two statements:

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

Specifying tt:read-write has the same effect as the statements tt:read and tt:read specified one directly after the other.

The attribute type and the attributes length and decimals specified using this attribute are used by tt:read only. As with tt:read, the attribute length can only be specified together with type.


Example

Serialization and Deserialization Using a Variable In serializations, the variable VARI is assigned the values of the data object bound to ROOT and is written to XML using read-write. In deserializations, the value of the variable is read from XML and assigned to the data object bound to ROOT.

<tt:transform

  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:variable name="VARI"/>
  <tt:template>
    <tt:assign ref="ROOT" to-var="VARI"/>
    <X>
      <tt:read-write var="VARI" type="STRING"
                                minLength="10"/>
    </X>
    <tt:assign to-ref="ROOT" var="VARI"/>
  </tt:template>
</tt:transform>

The following ABAP program can call the transformation:

DATA  str TYPE string.
DATA xstr TYPE xstring.

CALL TRANSFORMATION kellerh_test
     SOURCE root = string`abcde`
     RESULT XML xstr.

cl_abap_browser=>show_xml( xml_xstring = xstr ).

CALL TRANSFORMATION kellerh_test
     SOURCE XML xstr
     RESULT root = str.

The result of the serialization is:

<X>abcde     </X>

The transformation is not symmetrical, due to minLength. After deserialization, the string str has at least 10 positions.