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: 

Function module to get last date of previous month .

naval_bhatt4
Contributor
0 Kudos

Hi all

Is there any Function module or some code snippet to get last date of previous month ?

thanks in Advance ,

Naval Bhatt

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor

hi,

you can do the following:

DATA : date TYPE sy-datum.

date = sy-datum. "Today
date+6(2) = '01'. "First day of this month
date = date - 1. "Previous day before first day of this month = last day of last month

hope this helps

ec

10 REPLIES 10

JozsefSzikszai
Active Contributor

hi,

you can do the following:

DATA : date TYPE sy-datum.

date = sy-datum. "Today
date+6(2) = '01'. "First day of this month
date = date - 1. "Previous day before first day of this month = last day of last month

hope this helps

ec

0 Kudos

So Simple yet so brilliant

Former Member
0 Kudos

pls use below 2 FM's

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

EXPORTING

months = -1

olddate = curent_date

IMPORTING

newdate = w_prevdate.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = w_prevdate

IMPORTING

last_day_of_month = w_lastdayprevmonth

EXCEPTIONS

day_in_no_date = 1

OTHERS = 2.

former_member156446
Active Contributor
0 Kudos

DATE_CHECK_PLAUSIBILITY Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.

DATE_COMPUTE_DAY Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.

DATE_GET_WEEK will return the week that a date is in.

DATE_IN_FUTURE Calculate a date N days in the future.

DAY_ATTRIBUTES_GET Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more.(provided by Francois Henrotte)

former_member386202
Active Contributor

Hi,

Use FM OIL_LAST_DAY_OF_PREVIOUS_MONTH

Regards,

Prashant

Former Member
0 Kudos

hi

good

You can use FM OIL_LAST_DAY_OF_PREVIOUS_MONTH to get last day of previous month.

Or you can use FM HR_JP_ADD_MONTH_TO_DATE to calculate previous months date by passing -1 and current date as input parameters and then use above FM to get first and last day.

hope this would help to solve your problem.

Thanks

mrutyun^

Former Member
0 Kudos

Hi,

use below function module

FKK_LAST_DAY_OF_MONTH

provide any date of the month for which u need to get last day.

Former Member

data:

w_date type sy-datum,

w_last_premonth type sy-datum,

w_days(2) type n.

w_date = sy-datum.

w_days = w_date+6(2).

w_last_premonth = w_date - w_days.

write w_last_premonth.

Edited by: jagadeesh tirumalasetti on Jul 7, 2008 9:31 AM

Former Member
0 Kudos

Hi,

Try this Function Module,

OIL_LAST_DAY_OF_PREVIOUS_MONTH.

Hope this helps you.

Reward points if helpfull.

Thanks & Regards.

Y.R.Prem Kumar

Former Member
0 Kudos

FM OIL_LAST_DAY_OF_PREVIOUS_MONTH