08-10-2007 10:58 AM
Hi all,
Please help me to find function module.
I want last date of previous month.when i write today date as input.
Thanking you in advance.
08-10-2007 11:00 AM
08-10-2007 11:00 AM
08-10-2007 11:01 AM
Hi,
You can use FM RP_LAST_DAY_OF_MONTHS.
DATA: WA_DATE LIKE SY-DATUM,
WA_LDATE LIKE SY-DATUM.
WA_DATE = SY-DATUM - 30.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = WA_DATE
IMPORTING
LAST_DAY_OF_MONTH = WA_LDATE
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2.
WRITE: / WA_LDATE.
<b>OR</b>
data: last_month_last_day type sy-datum.
last_month_last_day = sy-datum.
last_month_last_day+6(2) = '01'.
last_month_last_day = last_month_last_day - 1.
write:/ last_month_last_day.
Yes, it works, all the time. Even in January.
reward if it helps..
Regards,
Omkar.
08-10-2007 11:04 AM
You can get the previous month by using FM CCM_GO_BACK_MONTHS
and its last day by using FM <b>SG_PS_GET_LAST_DAY_OF_MONTH</b>, <b>BKK_GET_MONTH_LASTDAY</b>.
Regards,
Pavan
08-10-2007 11:04 AM
u can make the code work like this.
data: date like sy-datum,
date1 like sy-datum.
date = sy-datum.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = date
IMPORTING
LAST_DAY_OF_MONTH = date1
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
.
add 1 to date1.
write:/ 'next month start date:', date1.
*to fetch the march month last date.
date1+4(2) = 03.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = date1
IMPORTING
LAST_DAY_OF_MONTH = date1
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
.
write:/ 'last date of march:', date1.
Regards,
Pavan