SAP/ABAP 코드

(ABAP 코드) DATE_TIME_CONVERSION

haramang 2022. 9. 4. 19:38


** https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abensql_date_time_conversions.htm

*
*... TSTMP_TO_DATS( tstmp    = tstmp,
*                   tzone    = tzone[,
*                   client   = client][,
*                   on_error = on_error] )
*  | TSTMP_TO_TIMS( tstmp    = tstmp,
*                   tzone    = tzone[,
*                   client   = client][,
*                   on_error = on_error] )
*  | TSTMP_TO_DST(  tstmp    = tstmp,
*                   tzone    = tzone[,
*                   client   = client][,
*                   on_error = on_error] )
*  | DATS_TIMS_TO_TSTMP( date     = date,
*                        time     = time,
*                        tzone    = tzone[,
*                        client   = client][,
*                        on_error = on_error] )
*  | TSTMPL_TO_UTCL( tstmpl = tstmpl[,
*                    on_error = on_error],[
*                    on_initial = on_initial] )
*  | TSTMPL_FROM_UTCL( utcl = utcl[,
*                      on_null = on_null] )
*  | DATS_TO_DATN( dats = dats[,
*                  on_error = on_error],[
*                  on_initial = on_initial] )
*  | DATS_FROM_DATN( datn = datn[,
*                    on_null = on_null] )
*  | TIMS_TO_TIMN( tims = tims[,
*                  on_error = on_error] )
*  | TIMS_FROM_TIMN( timn = timn[,
*                    on_null = on_null] )...

DATAlv_tzone type TIMEZONE.


CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
  IMPORTING
    timezone lv_tzone.

SELECT carriddats_tims_to_tstmpdate @sy-datum,
                                   time @sy-uzeit,
                                   tzone @lv_tzone AS stamp
  FROM scarr
  INTO TABLE @DATA(aa).





DATA ts TYPE timestampl.
GET TIME STAMP FIELD ts.

DATA(utcutclong_current).

DELETE FROM demo_expressions.
INSERT demo_expressions FROM @VALUE #id 'X'
                                         dats1 sy-datum
                                         tims1 sy-uzeit
                                         timestampl1 ts
                                         utcl1 utclong_current).

DATA tzone TYPE timezone.
CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
  IMPORTING
    timezone tzone.

SELECT SINGLE
       FROM demo_expressions
       FIELDS
         tstmp_current_utctimestamp)
             AS tstmp,
         tstmp_to_dats(
           tstmp    tstmp_current_utctimestamp),
           tzone    @tzone,
           client   @sy-mandt,
           on_error @sql_tstmp_to_dats=>set_to_null )
             AS dat,
         tstmp_to_tims(
           tstmp    tstmp_current_utctimestamp),
           tzone    @tzone,
           client   @sy-mandt,
           on_error @sql_tstmp_to_tims=>set_to_null )
             AS tim,
         tstmp_to_dst(
           tstmp    tstmp_current_utctimestamp),
           tzone    @tzone,
           client   @sy-mandt,
           on_error @sql_tstmp_to_dst=>set_to_null )
             AS dst,
           dats_tims_to_tstmp(
             date     dats1,
             time     tims1,
             tzone    @tzone,
             client   @sy-mandt,
             on_error @sql_dats_tims_to_tstmp=>set_to_null )
               AS dat_tim,
         tstmpl_to_utcl(
           tstmpl    timestampl1,
           on_error @sql_tstmpl_to_utcl=>c_on_error-set_to_null,
           on_initial =
           @sql_tstmpl_to_utcl=>c_on_initial-set_to_initial )
             AS utcl,
         tstmpl_from_utcl(
           utcl utcl1,
           on_null @sql_tstmpl_from_utcl=>c_on_null-set_to_null )
             AS from_utcl
       INTO @DATA(result).


BREAK-POINT.