SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → asXML - Canonical XML Representation → asXML - Mapping of ABAP Data Types →asXML - Mapping of Elementary ABAP Types
The asXML representation of elementary ABAP types is used in XSL transformations and in Simple Transformations. In both cases, the elementary values or the elementary components of complex structures are converted in accordance with this mapping.
For elementary data objects with predefined ABAP types, the as representation is based on the canonical representation of XML schema data types from the namespace xsd="http://www.w3.org/2001/XMLSchema", where dates and times are represented in accordance with ISO-8601 and binary data is represented in accordance with Base64. The mapping of ABAP types to the XML schema data types is not fully bijective, due to the different value ranges. For example, you can specify a time zone for the XML schema data type xds:date, whereas this is not possible for the ABAP type d.
The following tables show a summary of the mappings:
Numeric Data Types
ABAP Type | ABAP Representation | XML Schema Type | XML Representation |
b | 123 | xsd:unsignedByte | 123 |
s | -123 | xsd:short | -123 |
i | -123 | xsd:int | -123 |
p | -1.23 | xsd:decimal | -1.23 |
decfloat16 | 123E+1 | precisionDecimal, totalDigits = 16 | 1.23E+3 |
decfloat34 | -3.140...0E+02 | precisionDecimal, totalDigits = 34 | -314.0...0 |
f | -3.140...0E+02 | xsd:double | -3.14E2 |
Note
The type precisionDecimal is not yet an official XML schema type.
Character-Like Data Types
ABAP Type | ABAP Representation | XML Schema Type | XML Representation |
c | " Hi" | xsd:string | _Hi |
string | " Hello " | xsd:string | _Hello_ |
n | "001234" | xsd:string (pattern [0-9]+) | 001234 |
d | "20020204" | xsd:date | 2002-02-04 |
t | "201501" | xsd:time | 20:15:01 |
Byte-Like Data Types
ABAP Type | ABAP Representation | XML Schema Type | XML Representation |
x | ABCDEF | xsd:base64Binary | q83v |
xstring | 456789AB | xsd:base64Binary | RweJqw== |
Differences in Serialization
In serializations, ABAP values are converted to the appropriate character-like XML format. Deserializations operate in the opposite direction. Note the following differences to the usual conversion rules that apply in ABAP.
Any violations of these rules raise handleable exceptions, some of which can be avoided by specifying a transformation option after the OPTIONS addition of the CALL TRANSFORMATION statement.
Note
To check the validity of dates and times, you can use the domains XSDDATE_D and XSDTIME_T instead of the data types d and t.
Special Features of Deserialization
Any violations of these rules raise handleable exceptions such as CX_SY_CONVERSION_DATA_LOSS, some of which can be avoided by specifying a transformation option after the OPTIONS addition of the CALL TRANSFORMATION statement.
Note
Exceptions from mappings cannot be handled directly. Instead, the exception CX_TRANSFORMATION_ERROR (or one of its subclasses) from statement CALL TRANSFORMATION can be handled. The attribute PREVIOUS then contains a reference to the original exception.
Example
See asXML, Mapping of Elementary Data Types