Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Abap General

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

OIL_LAST_DAY_OF_PREVIOUS_MONTH

Regards

Peram

4 REPLIES 4

Former Member
0 Kudos

OIL_LAST_DAY_OF_PREVIOUS_MONTH

Regards

Peram

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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