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 

Simple Transformation, tt:value

Serializes and deserializes elementary data objects

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: dat TYPE d,
          tim TYPE t,
          ts  TYPE utclong,
          tsp TYPE xsddatetime_z.

    dat = sy-datlo.
    tim = sy-timlo.
    CONVERT DATE dat
            TIME tim
            TIME ZONE ``
            INTO UTCLONG ts.
    tsp = cl_abap_tstmp=>utclong2tstmp_short( ts ).

    CALL TRANSFORMATION demo_st_value
      SOURCE date      = dat
             time      = tim
             datetime1 = ts
             datetime2 = tsp
      RESULT XML DATA(xml).

    cl_demo_output=>display_xml( xml ).

Description

The transformation in question, DEMO_ST_VALUE, shows the mapping of elementary ABAP data types for date, time, and time stamp to XML and back.

<?sap.transform simple?>
<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="DATE"/>
  <tt:root name="TIME"/>
  <tt:root name="DATETIME1"/>
  <tt:root name="DATETIME2"/>
  <tt:template>
    <Date_and_Time>
      <Date>
        <tt:value ref="DATE"/>
      </Date>
      <Time>
        <tt:value ref="TIME"/>
      </Time>
      <DateTime1>
        <tt:value ref="DATETIME1"/>
      </DateTime1>
      <DateTime2>
        <tt:value ref="DATETIME2"/>
      </DateTime2>
    </Date_and_Time>
  </tt:template>
</tt:transform>

Note that tsp is defined with the special type XSDDATETIME_Z from ABAP Dictionary. This type ensures that a special mapping is used for time stamps in packed numbers. This happens by default for the built-in time stamp type utclong.

The transformation is symmetrical.