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 - Transformation of ABAP Values →  ST - tt:value, Elementary Data Objects 

ST - map, Mapping List

Other versions: 7.31 | 7.40 | 7.54

Syntax


... map="..., val(a1, a2, ...) > xml(x), ..." ... 
... map="..., xml(x1, x2, ...) > val(a), ..." ...
... map="..., val(a) = xml(x), ..." ...
... map="..., xml(x) = val(a), ..." ...

Effect

The attribute map is used to specify a mapping list for tt:value, tt:write, and tt:read. This is done to map a list of explicitly specified values to precisely one value when serializing or deserializing. A mapping list consists of a single mapping rule or a comma-delimited list of multiple mapping rules. The following mapping rules are possible:

  • val(a1, a2, ...) > xml(x)
This mapping rule is analyzed in serializations. If the value of the current data node matches one of the specified values a1, a2, ... it is transformed to the value x.
  • xml(x1, x2, ...) > val(a)
This mapping rule is analyzed in deserializations. If the value of the current node matches one of the specified values x1, x2, ... it is transformed to the ABAP value a.
  • val(a) = xml(x) and xml(x) = val(a)
These mapping rules both mean the same thing and are analyzed in both serializations and deserializations. If the value of the current node corresponds to the specified value a, it is converted into value x, and vice versa.

The values a, a1, a2, ... must be specified in accordance with the representation of ABAP values. The XML values x, x1, x2, ... must be put in quotation marks.


Note

If mapping rules with more than one argument are used, transformation is usually no longer symmetrical.


Example

Serialization of ABAP data using a mapping list:

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT1"/>
  <tt:root name="ROOT2"/>
  <tt:template>
    <X0>
      <X1>
        <tt:value  ref="ROOT1"
            map="val(C('Woman'), C('Man')) > xml('Person')" />
      </X1>
      <X2>
        <tt:value  ref="ROOT2"
            map="val(C('Woman'), C('Man')) > xml('Person')" />
      </X2>
    </X0>
  </tt:template>
</tt:transform>

The transformation is not symmetrical. In the following ABAP program, field1 and field2 contain the value "Person" after deserialization.

DATA xml_string TYPE string.

DATA field1 TYPE string VALUE 'Woman'.
DATA field2 TYPE string VALUE 'Man'.

CALL TRANSFORMATION ...
  SOURCE root1 = field1
         root2 = field2
  RESULT XML xml_string.

CALL TRANSFORMATION ...
  SOURCE XML xml_string
  RESULT root1 = field1
         root2 = field2.