Start of Content Area

Syntax documentation Elementary Data Objects  Locate the document in its SAP Library structure

The following ST command is used to serialize and de-serialize elementary data objects:

 

<tt:value [ref=“node“] [map=“mapping_list“] />

 

The optional attribute ref can be used to define the current node for the command. If refis not specified, the current node of the surrounding element is used.

Serialization

If you do not specify map, during seríalization the value of the elementary ABAP data object, which is bound to the current node, is inserted into the XML document in place of the command.

Deserialization

During deserialization, the current value of the XML inbound stream is passed to the ABAP data object. The ending of the XML value is determined either by the end of the text node (for example, at the element ending) or by the beginning of a literal text following directly in the ST program. The XML value must correspond to the type of the data object and must lie within its value range.

 

Value Representation in XML

Like in asXML, the XML representation of the content of elementary data objects corresponds to the canonical representation of XML schema data types (http://www.w3.org/TR/xmlschema-2/#built-in-datatypes). The date and time are displayed in accordance with ISO-8601 and binary data corresponds to base 64:

ABAP Type

ABAP Example

XML Schema Type

XML Example

c

" Hi"

string

" Hi"

d

"20020204"

date

"2002-02-04"

f

-3.140...0E+02

double

"-3.14E2"

i, b, s

-123

int, unsignedByte, short

"-123"

n

"001234"

string (pattern [0-9]+)

"001234"

p

-1.23

decimal

"-1.23"

string

" Hello "

string

" Hello "

t

"201501"

time

"20:15:01"

x

"ABCDEF"

base64Binary

"q83v"

xstring

"456789AB"

base64Binary

"RweJqw=="

 

Mapping List

You can use the map attribute to specify a mapping_list, in order to map a list of explicitly specified values to a single value during serialization and deserialization.

A mapping_list consists of a single mapping rule or a comma-delimited list of several mapping rules. The following mapping rules are possible:

·        val(a1, a2, ...) > xml(x)

This mapping rule is analyzed during serialization. If the value of the current data node corresponds to one of the specified values a1, a2, ..., it is converted to value x.

·        xml(x1, x2, ...) > val(a)

This mapping rule is analyzed during deserialization. If the value of the current data node corresponds to one of the specified values x1, x2, ..., it is converted to ABAP value a.

·        val(a) = xml(x)
xml(x) = val(a)

These mapping rules both mean the same thing and are analyzed during both serialization and deserialization. If the value of the current node corresponds to the specified value a, it is converted to value x, and vice versa.

The values a, a1, a2, ... must be specified as described in the Appendix. The XML values x, x1, x2, … must be included in inverted commas.

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>
      <X1>
        <tt:value  ref="ROOT1"
                   map="val(C('Woman'), C('Man')) > xml(C('Person'))" />
      </X1>
      <X2>
        <tt:value  ref="ROOT2"
                   map="val(C('Woman'), C('Man')) > xml(C('Person'))" />
      </X2>

  </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.

 

 

 

 

End of Content Area