Code: Alles auswählen.
METHOD date_add_seconds.
DATA
: ld_days TYPE i
, ld_time TYPE i
, ld_secs TYPE i
.
" Get target date...
ld_days = FLOOR( id_secs / sec_24h ).
ed_date = id_date + ld_days.
ld_secs = id_secs - ( ld_days * sec_24h ).
" Get target time
ld_time = id_time + ld_secs.
IF ld_time >= sec_24h.
ld_time = ld_time - sec_24h.
ed_date = ed_date + 1.
ELSEIF ld_secs < 0.
IF abs( ld_secs ) > id_time.
ed_date = ed_date - 1.
ENDIF.
ENDIF.
ed_time = ld_time.
ENDMETHOD.
Code: Alles auswählen.
" Value 86400 = 1 Tag in Sekunden
DATA: dayseconds TYPE i VALUE 86400,
timestamp TYPE tzntstmpl,
resultstamp TYPE tzntstmpl.
GET TIME STAMP FIELD timestamp.
"Berechnung
TRY.
resultstamp = cl_abap_tstmp=>subtractsecs(
tstmp = timestamp
secs = dayseconds
).
CATCH cx_parameter_invalid_range .
CATCH cx_parameter_invalid_type .
ENDTRY.