Get Example source ABAP code based on a different SAP table
ABAP_ASXML - Mapping Additional XML Schema Data Types In addition to the XML schema data types> required for mapping elementary ABAP types>, there are additional XML schema data types for which there is no direct equivalent in the form of built-in ABAP types. To enable type-friendly deserialization of these external types to ABAP data objects, a special DDIC domain> is implemented in the ABAP Dictionary for each required XML schema data type. The name of the domain starts with XSD>. Any elementary ABAP data objects whose data type is defined using a DDIC data element> that refers to such a DDIC domain are mapped to the associated XML schema data type, both when serialized and when deserialized. The required conversions are performed internally. This applies to both XSL transformations and to Simple Transformations. The following table provides a summary of the XML schema data types supported by domains and additionally supported types (UUID>, currCode> and unitCode>). XML Schema Type>XML Representation>Domain> ABAP Representation> xsd:boolean>true>, false> XSDBOOLEAN>>X>, blank xsd:date>2007-10-01> XSDDATE_D>>20071001> xsd:time>11:55:00> XSDTIME_T>>115500> xsd:dateTime>2006-07-27T17:03:34Z> XSDDATETIME_Z>>, XSDDATETIME_LONG_Z>>, XSDDATETIME_OFFSET>>, XSDDATETIME_LOCAL>>, XSDDATETIME_LOCAL_DT>> 20060727170334> xsd:QName>prefix:name> XSDQNAME>>{URI}name> UUID>00505691#3e2f#1ed5#b8ba#87b9ac1248c9> XSDUUID_RAW>>, XSDUUID_CHAR>>, XSDUUID_BASE64>> 005056913E2F1ED5B8BA87B9AC1248C9>, lbr 051MaJul7jMukeUvh198oG> xsd:language>EN>, DE>XSDLANGUAGE>>D>, E> currCode>EUR>, USD> XSDCURRCODE>>EUR>, USD> unitCode>KMT>, SMI> XSDUNITCODE>>KM>, MI> The following sections describe the domains and their mappings in more detail. ITOC The following applies to all domains:
in deserializations of an empty XML element in an ABAP data object, which is typed with reference to this type of domain, the initial value of the associated elementary ABAP type is assigned as usual.
The transformation option initial_components>> for suppressing initial values in serializations has the same effect as for regular data types. This can lead to unexpected behavior in deserializations, if the transformation option clear>> is not used with the value all>.
Latest notes:
By specifying format>> in the attribute option>> of the ST statement tt:value>>, many of the formats here can also be applied to ABAP data objects that are not typed with a domain of this type.
By specifying regime>> in the attribute option>> of the ST statement tt:value>>, the effect of the domains shown here is disabled.
Exceptions that occur when mapping the domains shown here can in some cases be suppressed by specifying noError>> in the attribute option>> of the ST statement tt:value>>.
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.
Apart from XSDQNAME>, all domains are also supported in transformations for JSON>. NON_V5_HINTS
See the associated executable example >. ABAP_HINT_END
<(>boolean<)> The domain XSDBOOLEAN>> has the data type CHAR> with length 1 and therefore supports the usual ABAP representation of a truth value> using X> for true and blank for false. These values are entered as fixed values> for the domain and are checked when an ABAP data object linked to this domain is serialized. The serialization creates the values true> and false> in XML. A deserialization also accepts the non-canonical XML values 1 > and 0>. Any other values raise the exception CX_SY_CONVERSION_NO_BOOLEAN>. An empty element creates the value blank in deserializations.
Latest notes:
By specifying noError>> in the attribute option>> of the ST statement tt:value>>, an exception for invalid ABAP values in serialization can be avoided. All values except blank are then interpreted as true.
The transformation option initial_components>> suppresses components of type XSDBOOLEAN> in serializations, if the components contain the value blank for false>. Therefore, this option should be used carefully.
The return value of the Boolean function xsdbool>> has the type XSDBOOLEAN>. NON_V5_HINTS ABAP_HINT_END
date The XML schema data type date> for dates is supported by both the built-in ABAP type d>> and the domain XSDDATE_D>>. This domain has the data type DATS>. When data is serialized and deserialized, the validity of the date is also checked, which is not the case with the built-in ABAP type d>. An empty element creates the value 00000000> in deserializations.
Latest notes: By specifying noError>> in the attribute option>> of the ST statement tt:value>>, an exception for an invalid date in serialization can be prevented again. NON_V5_HINTS ABAP_HINT_END
<(>dateTime<)> The XML schema data type dateTime> supports the representation of dates and times in a field, based on ISO 8601. An XML value of this type is either in UTC format, contains a time zone, or represents a local time. Five domains are assigned to this schema data type:
The domains XSDDATETIME_Z>> and XSDDATETIME_LONG_Z>> have the data types DEC> with length 15 or 21. XSDDATETIME_Z> has no decimal places and XSDDATETIME_LONG_Z> has seven decimal places. These domains support the long and short form of time stamps in packed numbers>, which is always interpreted as the current UTC> reference time. The serialization generates values in the UTC format ( yyyy-mm-ddThh:mm:ss.fffffffZ>) in XML. Only significant decimal places are written to XML. A deserialization accepts XML values in UTC format (closed by Z>) or with time zones (closed by ${+$|-$}hh:mm>). The time zones are converted to the associated UTC value. No precision may be lost in deserializations. This means that only XML values with a maximum of seven decimal places can be deserialized. An empty element creates the value 0 in deserializations.
The domain XSDDATETIME_OFFSET>> has the data type CHAR> with length 18. It allows mappings to XML values in which a time zone is specified ( yyyy-mm-ddThh:mm:ss${+$|-$}hh:mm>). The predefined format for an ABAP data object of type XSDDATETIME_OFFSET> is yyyymmddhhmmss${+$|-$}mmm>. In a deserialization, the time zone of the XML value specified in hours and minutes is converted to a three-digit number of minutes and vice versa in serializations. An empty element creates a string filled with blanks in deserializations.
The domain XSDDATETIME_LOCAL>> has the data type CHAR> with length 14. The domain XSDDATETIME_LOCAL_DT>> has the data type NUMC> with length 14. They enable mappings to XML values that specify a local time (yyyy-mm-ddThh:mm:ss>). This means that they do not exist in UTC format and no time zone is specified. The predefined format for an ABAP data object of type XSDDATETIME_LOCAL> or XSDDATETIME_LOCAL_DT> is yyyymmddhhmmss>. The main differences between the two data types are their initial values. An empty element creates a string filled with blanks or zeros in deserializations. Invalid values raise the exception CX_SY_CONVERSION_NO_DATE_TIME>.
Latest notes: Time stamp fields with time stamp type> are mapped to the format yyyy-mm-ddThh:mm:ss.fffffffZ> by default. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Serialization and deserialization of a time stamp field of the type utclong> and a time stamp in a packed number of the type XSDDATETIME_LONG_Z>. The generated XML is as follows: < asx:abap version='1.0' xmlns:asx='http://www.sap.com/abapxml'> < asx:values> < TS>2019-04-15T11:22:10.1230000Z < /TS> < TSP>2019-04-15T11:22:10.123Z < /TSP> < /asx:values> < /asx:abap>> The element < TS>> and element < TSP>> can be deserialized in both time stamp fields and in packed numbers of the type XSDDATETIME_LONG_Z>. ABEXA 00813 ABAP_EXAMPLE_END
<(>QName<)> The domain XSDQNAME>> has the data type STRING>. The XML schema data type QName> represents qualified names. In XML, a qualified name can have a prefix that is separated by a colon. A prefix of this type must be linked with a URI in a namespace declaration of the current element or a higher-level element. In ABAP, a name of this type is represented as the content of a string in the form {URI}name>. When an ABAP object of the type XSDQNAME> is serialized, the URI specified in curly brackets is used to create the associated prefix. If there is no namespace declaration for the URI in the right context, it is inserted in the current element, with the resulting namespaces being given the names n0>, n1>, ... If the URI is linked with the default namespace, no prefix is created. If no URI is specified in curly brackets, no prefix is created either. This latter case is possible only if the default namespace is not used simultaneously in the current element. Otherwise, the exception CX_ST_INVALID_XML> is raised, which can occur only in Simple Transformations. When a value with a prefix is deserialized to an ABAP data object of the type XSDQNAME>, the URI is searched for in a linked namespace declaration. If no URI is found, the exception CX_SY_CONVERSION_NO_QNAME> is raised. If a value without prefix is deserialized, the URI of the default namespace is used (if available) or only the name is placed in the string. An initial data object of the type XSDQNAME> creates an empty element when serialized and vice versa when deserialized. In both serializations and deserializations, the correctness of the specified name with respect to the valid naming conventions is checked. If violated, an exception of the class CX_SY_CONVERSION_NO_QNAME> is raised. The class CL_ABAP_XSDTYPE_HELPER>> contains the methods TO_XSDQNAME> and FROM_XSDQNAME> for the conversion of URIs and names to the type XSDQNAME> and vice versa.
ABAP_EXAMPLE_ABEXA asXML, Mapping of Qualified Names> ABAP_EXAMPLE_END
time The XML schema data type time> for times is supported by both the built-in ABAP type t>> and the domain XSDTIME_T>>. This domain has the data type TIMS>. When data is serialized and deserialized, the validity of the time is also checked, which is not the case with the built-in ABAP type t>. An empty element creates the value 000000> in deserializations.
Latest notes: Specifying noError>> in the attribute option>> of the ST statement tt:value>> again prevents an exception due to an invalid time in serializations. NON_V5_HINTS ABAP_HINT_END
UUID The domains have the following meaning:
XSDUUID_RAW>> has the data type RAW> with length 16 for 16-byte UUIDs> in binary format.
XSDUUID_CHAR>> has the data type CHAR> with length 32 for 16-byte UUIDs> in hexadecimal format.
XSDUUID_BASE64>> has the data type CHAR> with length 22 for 16-byte UUIDs> in base64> format. A serialization creates the hexadecimal XML schema representation from data objects of these types, with hyphens and lowercase letters. Deserializations accept uppercase letters as well. A character-like UUID of type XSDUUID_CHAR> can contain only uppercase letters in serializations. Invalid UUIDs raise the exception CX_SY_CONVERSION_NO_UUID>. An empty element creates byte strings or character strings filled with hexadecimal zeros or blanks in deserializations.
Latest notes: UUIDs can be generated in ABAP data objects by the class CL_SYSTEM_UUID>>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Serialization of a 16-byte UUID> in base64> format. ABEXA 00814 ABAP_EXAMPLE_END