In case you want to add months to a date filed and get the resulting Day, Month and year you can use the following function module.
MONTH_PLUS_DETERMINE
The above mentioned function module accepts the date in SY-DATUM type and months in NUMC. The 2 Parameters are imported in the function module and processed and the resulting date is exported to the calling program. Please see the program given below.
REPORT ZEX_ADDMONTHSTOYEAR .
Parameters: P_Months(4) type n,
P_odate like sy-datum.
Data: D_NewDate like sy-datum.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
MONTHS = P_Months
OLDDATE = P_odate
IMPORTING
NEWDATE = D_NewDate.
Write:/ 'New Date is ', D_NewDate.
We will see the output of the above program for the following inpu.Parameters: P_Months(4) type n,
P_odate like sy-datum.
Data: D_NewDate like sy-datum.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
MONTHS = P_Months
OLDDATE = P_odate
IMPORTING
NEWDATE = D_NewDate.
Write:/ 'New Date is ', D_NewDate.
P_MONTHS = 10
P_odate = 05/05/2004
P_odate = 05/05/2004
The Output would be as follows.
Add Months To Year
New Date is 03/05/2005
New Date is 03/05/2005
No comments:
Post a Comment