The following ABAP code adds n number of WORKING days to a particular date, any days which are not
workings days (i.e. Saturday) will be ignored. For example if your starting date is Friday, adding 3 days
would return a result of Wednesday or if starting date was Wednesday resultant day would be Monday as
Saturday and Sunday are non working days. If you want to add n number of working days but allow result
to be a non working day then click here for alternative ABAP code.
Simply add the below FORM into you code and call it using the usual PERFORM command: PERFORM add_working_days USING ld_numdays
CHANGING gd_date.
**&---------------------------------------------------------------------* *& Form ADD_WORKING_DAYS *&---------------------------------------------------------------------* * Add n number of factory days(working days) to date *----------------------------------------------------------------------* * <-- P_DAYS Number of days to add * <-- P_PAYDATE Starting date *----------------------------------------------------------------------* FORM add_working_days USING p_days CHANGING p_paydate TYPE sy-datum. DATA: gd_factorydat LIKE scal-facdate, gd_resdate LIKE sy-datum.
* Convert date to factory date CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE' EXPORTING date = p_paydate "Starting date factory_calendar_id = 'GB' IMPORTING factorydate = gd_factorydat. "Factory calender date
* Add n number of days to factory date, ignors non working days gd_factorydat = gd_factorydat + p_days.
* Convert factory date back to actual date CALL FUNCTION 'FACTORYDATE_CONVERT_TO_DATE' EXPORTING factorydate = gd_factorydat factory_calendar_id = 'GB' IMPORTING date = gd_resdate. "Actual date
p_paydate = gd_resdate. ENDFORM. " ADD_WORKING_DAYS
|
No comments:
Post a Comment