Simply add the below FORM into you ABAP code and call it using the usual PERFORM command: DATA: ld_date TYPE 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
|
No comments:
Post a Comment