I have a program in ABAP where they use the type 'timestampl' in a variable, so they can get the time of certain events. They use it because they need the milliseconds.
I now have the mission of getting the difference between 2 of these variables, and I can't seem to find a function module or another solution.
Any help is much appreciated!
Use the method CL_ABAP_TSTMP=>SUBTRACT, by passing two timestamps which must be of the type TIMESTAMPL so that to contain milliseconds, and the difference between the 2 timestamps will be returned in number of seconds, including the milliseconds.
Example:
DATA: lv_tstmp1 TYPE timestampl,
lv_tstmp2 TYPE timestampl,
lv_diff TYPE tzntstmpl.
lv_tstmp1 = '20190704000010.999'. " July 4th, 00:00:10 and 999 ms
lv_tstmp2 = '20190703235950.001'. " July 3rd, 23:59:50 and 001 ms
CALL METHOD cl_abap_tstmp=>subtract
EXPORTING
tstmp1 = lv_tstmp1
tstmp2 = lv_tstmp2
RECEIVING
r_secs = lv_diff.
ASSERT lv_diff = '20.998'. " expectation verified or run time error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With