Ansicht
Dokumentation

ABENABAP_XSLT_ASXML_SCHEMA - ABAP XSLT ASXML SCHEMA

ABENABAP_XSLT_ASXML_SCHEMA - ABAP XSLT ASXML SCHEMA

rdisp/max_wprun_time - Maximum work process run time   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

- Mapping Additional XML Schema Data Types

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, " "
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.

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

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.

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 " " 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 " " in deserializations.

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 " " are then interpreted as true.
  • The transformation option initial_components suppresses components of type XSDBOOLEAN in serializations, if the components contain the value " " for "false". Therefore, this option should be used carefully.
  • The return value of the Boolean function xsdbool has the type XSDBOOLEAN.

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.

Note

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.

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.

Note

Time stamp fields with time stamp type are mapped to the format yyyy-mm-ddThh:mm:ss.fffffffZ by default.

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.

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.

asXML, Mapping of Qualified Names

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.

Note

Specifying noError in the attribute option of the ST statement tt:value again prevents an exception due to an invalid time in serializations.

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.

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.

Note

UUIDs can be generated in ABAP data objects by the class CL_SYSTEM_UUID.

Example

Serialization of a 16-byte UUID in base64 format.

asXML, Mapping of UUIDs

language

The domain XSDLANGUAGE has the data type LANG with length 1. It allows mappings of one-character internal language codes to the associated two-character external ISO codes and vice versa. The rule for the mapping is specified in the columns SPRAS (single-character code) and LAISO (two-character code) of the database table T002. In serializations, the single-character code is searched for in the table T002 and the associated two-character code is used as an XML value. The opposite happens in deserializations. In deserializations, lowercase letters are transformed to uppercase letters first. If no code is found in the table T002, the following relationship is evaluated:

Y = ( X2 - 0x20 ) + ( X1 - 0x20 ) * ( 0x80 - 0x20 ) + 0xAC00

Here, Y is the 16-bit Unicode value of the single-character code and X1 and X2 are the 7-bit ASCII values of the two characters in the two-character code.

  • In serializations, an attempt is made to create a two-character code that satisfies this relationship. If this is not possible, the exception CX_SY_CONVERSION_UNKNOWN_LANGU is raised.
  • In deserializations, the single-character code is calculated in accordance with this formula. The exception CX_SY_CONVERSION_UNKNOWN_LANGU is raised if the XML value is longer than two characters (except when the third character is a hyphen, in which case only the first two characters are used) or if the 7-bit ASCII values of the characters are less than 0x20 or greater than or equal to 0x80.

Note

Specifying noError in the attribute option of the ST statement tt:value again prevents an exception due to an unknown language in serializations. In this case, no conversion is performed.

Example

Serializes a language code with transformation in accordance with table T002.

currCode

The domain XSDCURRCODE has the data type CUKY with length 5. It allows mappings of SAP-specific currency codes to external ISO currency codes and vice versa. The rule for the mapping is specified in the columns WAERS (SAP code) and ISOCD (ISO code) of the database table TCURC. In serializations, the SAP code is searched for in the table TCURC and the associated ISO code is used as an XML value and vice versa in deserializations. If a code is not found in the table TCURC, the exception CX_SY_CONVERSION_UNKNOWN_CURR is raised.

Note

Specifying noError in the attribute option of the ST statement tt:value again prevents an exception due to an unknown SAP code in serializations. In this case, no conversion is performed.

Example

Serializes a currency code with transformation in accordance with table TCURC.

unitCode

The domain XSDUNITCODE has the data type UNIT with length 3. It allows mappings of SAP-specific unit codes to external ISO unit codes and vice versa. The rule for the mapping is specified in the columns MSEHI (SAP code) and ISOCODE (ISO code) of the database table T006. In serializations, the SAP code is searched for in the table T006 and the associated ISO code is used as an XML value and vice versa in deserializations. If a code is not found in the table T006, the exception CX_SY_CONVERSION_UNKNOWN_UNIT is raised.

Note

By specifying noError in the attribute option of the ST statement tt:value, an exception for an unknown SAP code in serialization can be avoided. In this case, no conversion is performed.

Example

Serializes a unit of measurement with transformation in accordance with table T006.






ABAP Short Reference   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 29181 Date: 20240423 Time: 215413     sap01-206 ( 377 ms )