Application Development and Automation 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: 
Read only

Abap General

Former Member
0 Likes
581

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
Read only

Former Member
0 Likes
556

OIL_LAST_DAY_OF_PREVIOUS_MONTH

Regards

Peram

4 REPLIES 4
Read only

Former Member
0 Likes
557

OIL_LAST_DAY_OF_PREVIOUS_MONTH

Regards

Peram

Read only

Former Member
0 Likes
556

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.

Read only

Former Member
0 Likes
556

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

Read only

Former Member
0 Likes
556

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