Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] CATS – Difference between two times (CATSHOURS)

I had to calculate the difference between two times, even if the end time goes beyond the 0 o’clock day limit, e.g. 20:00 to 02:00 should be 6h. I found the following two function modules doing the job:

* Option 1
CALL FUNCTION 'CATS_COMPUTE_HOURS'
  EXPORTING
    pernr                    = pernr
    date                     = date
*   NO_BREAK_DEDUCTION       = ' '
    row                      = row
  TABLES
    return                   = return
  CHANGING
    catshours                = catshours
    beguz                    = beguz
    enduz                    = enduz
    vtken                    = vtken.

* Option 2 (I think it's only available on S/4 HANA)
CALL FUNCTION 'CATS_DETERMINE_HOURS'
  CHANGING
    catshours                = catshours
    beguz                    = beguz
    enduz                    = enduz.

Leave a Reply

Your email address will not be published. Required fields are marked *