Function module \’BKK_ADD_WORKINGDAY\’ is a nice FM that allows to add days to a date. The function module can also consider non-working days (like Saturday, Sunday and public holidays) based on the calendar maintained in the the system.
Below is a sample code of how to use the function module \’BKK_ADD_WORKINGDAY\’.
REPORT zadddaystodate.
*Data Declarations:
*Constants:
CONSTANTS:
lc_number_of_days_to_add TYPE i VALUE 1,
lc_holiday_cal_id TYPE scal-hcalid VALUE \'FR\'.
*Variables:
DATA:
lv_date TYPE sy-datum,
lv_added_date TYPE sy-datum,
lv_subrc TYPE sy-subrc.
*Input Date.
lv_date = \'20170301\'.
CALL FUNCTION \'BKK_ADD_WORKINGDAY\'
EXPORTING
i_date = lv_date
i_days = lc_number_of_days_to_add
* The parameter \'I_CALENDAR1\' allows the FM to consider
* non-working days (like Saturday, Sunday and public holidays) during
* the calculation of the new added date.
* i_calendar1 = lc_holiday_cal_id
IMPORTING
e_date = lv_added_date
e_return = lv_subrc.
IF lv_subrc EQ 0.
WRITE lv_added_date.
ENDIF.