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 - option, Mapping Rules →  ST - option, Mapping Rules for Elementary Types 

Simple Transformation, Option for Invalid Values

This example demonstrates how ABAP types are mapped using invalid values.

Other versions: 7.31 | 7.40 | 7.54

Source Code


    num = CONV d( `  1234  ` ).
    pack = -1234.
    ASSIGN pack TO <hex> CASTING.
            CONV xstring( '40' ) IN BYTE MODE.
    boolean = '1'.
    date = 'XXXXXXXX'.
    time = 'XXXXXX'.
    langu = '�'.
    currcode = '�����'.
    unitcode = '�����'.

        CALL TRANSFORMATION demo_st_noerror_option
          SOURCE n           = num
                 p           = pack
                 boolean     = boolean
                 xsddate_d   = date
                 xsdtime_t   = time
                 xsdlanguage = langu
                 xsdcurrcode = currcode
                 xsdunitcode = unitcode
          RESULT XML DATA(xml).
      CATCH cx_transformation_error INTO DATA(exc).
        cl_demo_output=>display( exc->get_text( ) ).

    cl_demo_output=>display_xml( xml ).


This example passes various types of ABAP data to the transformation DEMO_ST_NOERROR_OPTION and provides the result for XML. The transformation applies the option noError to the ABAP data:

<?sap.transform simple?>
<tt:transform xmlns:tt="">
  <tt:root name="N"/>
  <tt:root name="P"/>
  <tt:root name="BOOLEAN"/>
  <tt:root name="XSDDATE_D"/>
  <tt:root name="XSDTIME_T"/>
  <tt:root name="XSDLANGUAGE"/>
  <tt:root name="XSDCURRCODE"/>
  <tt:root name="XSDUNITCODE"/>
        <str name="n">
          <tt:value option="noError" ref="N"/>
        <str name="p">
          <tt:value option="noError" ref="P"/>
        <bool name="boolean">
          <tt:value option="noError" ref="BOOLEAN"/>
        <str name="xsddate_d">
          <tt:value option="noError" ref="XSDDATE_D"/>
        <str name="xsdtime_t">
          <tt:value option="noError" ref="XSDTIME_T"/>
        <str name="xsdlanguage">
          <tt:value option="noError" ref="XSDLANGUAGE"/>
        <str name="xsdcurrcode">
          <tt:value option="noError" ref="XSDCURRCODE"/>
        <str name="xsdunitcode">
          <tt:value option="noError" ref="XSDUNITCODE"/>

The transformation creates JSON-XML to represent both XML and JSON. The example passes an invalid value to the transformation for each of the types used. If the option noError were not specified, each of the invalid types would raise an exception.