Add n number of working days to date
The following ABAP code adds/Subtracts n number of months from a particular date. This is a very simple
processusing the 'MONTH_PLUS_DETERMINE' function module. If this function module does not exist please
see the more cumbersome solution using SAP FM CALCULATE_DATE.
Simply add the below FORM into you ABAP code and call it using the usual PERFORM command:
DATA: ld_date TYPE sy-datum. ld_date = sy-datum. PERFORM calculate_date using '-4' changing ld_date.
*&------------------------------------------------* *& Form CALCULATE_DATE *&-------------------------------------------------* * Add/Subtract n number of months from a date *--------------------------------------------------* * --> p_months Number of months to add/subtract * <-- p_date Start date and result date *--------------------------------------------------* FORM calculate_date USING p_months CHANGING p_date. DATA: ld_datestor TYPE sy-datum. ld_datestor = p_date. CALL FUNCTION 'MONTH_PLUS_DETERMINE' EXPORTING MONTHS = p_months OLDDATE = p_date IMPORTING NEWDATE = p_date. ENDFORM. " CALCULATE_DATE
Related Articles
Add n number of working days to date (allow result to be a non working day)
Add n number of working days to date
Formatting SAP date field using ABAP into any format such as DDMMYYY, MM/DD/YYYY, DD-MMM-YY...
Formatting a date field
Check if date periods overlap
Add n number of working days to date
Convert month value of a date to text
Add n number of working days to date using SAP personal work schedule
Add n number of working days to date (using personal work schedule)