SAP UTCLONG DIFF



Get Example source ABAP code based on a different SAP table
  


• utclong_diff ABAP_FUNCTION
• high utclong_diff function
• low utclong_diff function

ABAP_TSFUNC - utclong_diff

ABAP_SYNTAX
... utclong_diff( high = time_stamp2
low = time_stamp1 ) ...

What does it do?
This built-in function calculates the time difference between the values of two time stamp fields time_stamp2 and time_stamp1. The return value has the type decfloat34 and contains the exact difference in seconds rounded to seven decimal places. If the time stamp in time_stamp2 is later than the time stamp in time_stamp1, the result is positive. If the values are identical, the result is 0, otherwise it is negative.
Time stamp fields of the type utclong containing valid time stamps must be passed to the arguments high and low. time_stamp2 and time_stamp1 are time-stamp-like expression positions. An initial time stamp is handled like the smallest possible value of a time stamp.



Latest notes:

The system class CL_ABAP_UTCLONG contains a method DIFF with multiple output parameters for days, hours, minutes, and seconds across which the time difference is spread instead of just one return parameter.
If the function utclong_diff is used as an operand of an arithmetic expression, the calculation type decfloat34 is produced.
If the function utclong_diff is used as the right side of an assignment or other operand positions in which the return value is converted, the decimal places are converted in accordance with the general conversion rules for source field type decfloat34 , if necessary, and are not cut off. If the decimal places are to be cut off, the built-in function trunc can be applied to the return value.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Calculation of the time interval in microseconds of consecutive time stamps from an internal table.
ABEXA 01376
ABAP_EXAMPLE_END



Runtime Exceptions



Catchable Exceptions
CX_SY_CONVERSION_NO_DATE_TIME
Reason for error:
A time stamp specified for high or low is invalid.
Runtime error:
INVALID_UTCLONG

Non-catchable Exceptions
Reason for error:
An argument without a time stamp type is passed to high or low.
Runtime error:
TCHK_TYPE_LOAD
ABAP_NONCAT_END