Calculate the days, months and years between 2 dates.
FORM compute_2date_diff. DATA: lv_date1 LIKE sy-datum, lv_date2 LIKE sy-datum, lv_month TYPE pea_scrmm, lv_days TYPE pea_scrdd.*lv_date1 must be greater than lv_date2 lv_date1 = '20120201'. lv_date2 = '20120101'. CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES' EXPORTING date1 = lv_date1 date2 = lv_date2 OUTPUT_FORMAT = '05' IMPORTING* YEARS = months = lv_month days = lv_days EXCEPTIONS invalid_dates_specified = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.ENDFORM. "compute_2date_diff