Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Date and Time Processing →  Time Stamps →  Time Stamps in Packed Numbers 

GET TIME STAMP

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


GET TIME STAMP FIELD time_stamp. 

Effect

This statement uses the system time and system date of the AS ABAP to generate a UTC time stamp according to the POSIX standard and assigns it to the variable time_stamp of type p as a time stamp in a packed number.

The following can be specified for time_stamp:

  • An existing variable of the data type TIMESTAMP or TIMESTAMPL from ABAP Dictionary, in accordance with ABAP type p with length 8 or p with length 11, with seven decimal places. Depending on the data type, the time stamp is generated either in the short form or in the long form.
  • An inline declaration DATA(var), where a variable of type TIMESTAMP is declared.


Notes

  • The precision of the decimal places of the long form depends on the hardware (processor) of the current AS Instance host computer. The maximum resolution of 100 ns is not always reached. A resolution of a single-figure or two-figure number of microseconds is realistic.
  • A time stamp in its short form is the integer part of a time stamp in its long form. A long form time stamp cannot be used to generate the associated short form time stamp simply by making an assignment, since this would involve commercial rounding. The method MOVE of the system class CL_ABAP_TSTMP can be used instead.

Example

Generates two time stamps. An existing variable of the type TIMESTAMPL must be used for the long form. An inline declaration can be used for the short form. The time stamps must be given a special format for the output, since otherwise only numbers of type p would be displayed.

DATA tsl TYPE timestampl. 

GET TIME STAMP FIELD DATA(ts). 
GET TIME STAMP FIELD tsl. 

cl_demo_output=>new( 
  )->write( |{ ts  TIMESTAMP = ISO 
                  TIMEZONE = 'UTC' }| 
  )->write( |{ tsl TIMESTAMP = ISO 
                   TIMEZONE = 'UTC' }| 
  )->display( ). 

Exceptions

Non-Handleable Exceptions

  • Cause: The target field differs from TIMESTAMP or TIMESTAMPL with respect to type, length, and decimal places.
    Runtime error: GET_TIMESTAMP_FORMAT