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

Date calculation program

Former Member
0 Likes
794

hi,

i want the code to calculate

firstdate of next month

last date of current month

last date of next month

plzzz can any one help

<b><removed_by_moderator></b>

plz help me as early as possible.....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
775

hi,

try this code....

data today type d value '24000228'.

data w_date type d.

data x type i.

w_date = today.

write: 'given date is', w_date.

do.

w_date = w_date + 1.

x = w_date+6(2).

if x = 1.

write: / 'first date next month', w_date.

w_date = w_date - 1.

write: /' last date of current month', w_date.

w_date = w_date + 1.

exit.

endif.

enddo.

do.

w_date = w_date + 1.

x = w_date+6(2).

if x = 1.

w_date = w_date - 1.

write: /' last date of next month', w_date.

exit.

endif.

enddo.

4 REPLIES 4
Read only

Former Member
0 Likes
776

hi,

try this code....

data today type d value '24000228'.

data w_date type d.

data x type i.

w_date = today.

write: 'given date is', w_date.

do.

w_date = w_date + 1.

x = w_date+6(2).

if x = 1.

write: / 'first date next month', w_date.

w_date = w_date - 1.

write: /' last date of current month', w_date.

w_date = w_date + 1.

exit.

endif.

enddo.

do.

w_date = w_date + 1.

x = w_date+6(2).

if x = 1.

w_date = w_date - 1.

write: /' last date of next month', w_date.

exit.

endif.

enddo.

Read only

0 Likes
775

data w_date type sy-datum.

w_date = '20070215'. "sample date, you can change it or take input from user instead.

w_date+6(2) = '01'. "make current date to be 1st.

w_date = w_date + 62. "increment it, few days like morethan the current month.

w_date+6(2) = '01'. "date to 1st again.

w_date = w_date - 1. "decrement one day. it will give u the last date of next month.

write w_date.

<b><removed_by_moderator></b>

Message was edited by:

manjari kotta (and subsequently by moderator)

Read only

Former Member
0 Likes
775

firstdate of next monthCALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = date

IMPORTING

LAST_DAY_OF_MONTH = date1

EXCEPTIONS

DAY_IN_NO_DATE = 1

OTHERS = 2

.

CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'

EXPORTING

I_GJAHR = YEAR

I_PERIV = FISC_VAR

IMPORTING

E_FIRST_DAY = BEG_DATE

E_LAST_DAY = END_DATE

EXCEPTIONS

INPUT_FALSE = 1

T009_NOTFOUND = 2

T009B_NOTFOUND = 3.

try this function module

Read only

former_member188770
Active Participant
0 Likes
775

Hi,

Look at this FM

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = wg_toddate

backmonths = 1

IMPORTING

newdate = wg_lastmondt.