My own Function-Module to calculate duration between 2 dates and 2 times
I was searching for a function module that should calculate the duration of 2 tasks .
As result I need values separated into
Most standard function deliver only one(1) result and than this return value is from type F (floating number, like 2,34546787E-03) and I did not want to convert the result into integer. Other standard functions look like they could work, but when I checked them I found that they where calculation wrong!
So I came to the conclusion to copy+paste what ever I can and I wrote my own function module using the SAP function module ‘L_TO_TIME_DIFF’
Here it is (check attachment)
Please comment if you find a BUG, I will try to solve it.
I found and error and replaced attachment/coding…
another bug found (seconds where wrong when time_to < time_from)
next bug with time (seconds where wrong, when date_to = date_from AND time_to < time_from) 😛
We do not have function L_TO_TIME_DIFF on our newer system .
We do have it on the older one.....
I only know further function modules (like COPF_DETERMINE_DURATION) which are using "floating" return values.
You can use them instead L_TO_TIME_DIFF, but than you must convert the floating value (TYPE f) into integer (TYPE int4).
btw. please recognize that I have replaced my coding (minor bugs!)