User Tools

Site Tools


abap:time

Table of Contents

Time

Timestamp

Récupérer le timestamp :

DATA tsl TYPE timestampl. "On peut se contenter d'un timestamp en secondes,
DATA tsl2 TYPE timestampl. "il suffit d'utiliser le type timestamp (sans "l").
DATA deltal TYPE timestampl.
 
GET TIME STAMP FIELD tsl.
 
WAIT UP TO 1 SECONDS.
 
GET TIME STAMP FIELD tsl2.
 
deltal = tsl2 - tsl.

Headline

ABAP propose différents moyens pour obtenir un timestamp mais comme d'hab dès qu'on parle de time, gare à la timezone ! Pour faire le choses simplement, on peut utiliser la classe cl_abap_tstmp.

* Get timestamp from date
CALL METHOD cl_abap_tstmp=>systemtstmp_syst2utc
  EXPORTING
    syst_date = wlv_date
    syst_time = wlv_time
  IMPORTING
    utc_tstmp = wlv_ts.
* Get date from timestamp
  CALL METHOD cl_abap_tstmp=>systemtstmp_utc2syst
    EXPORTING
      utc_tstmp = wlv_ts
    IMPORTING
      syst_date = wlv_date
      syst_time = wlv_time.
abap/time.txt · Last modified: 2016/12/05 16:44 by ginko