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: 

i need date that is three months prior to current date or sy-datum

Former Member
0 Kudos

Hi All,

Please help me in this issue.

In the selection screen the lower limit of the select option should be last three months and on high it should be the sy-datum for ex

30.06.2007 30.09.2007

thanks in advance

thanks & regards

Kreddy

14 REPLIES 14

Former Member
0 Kudos

Hi,

you got the date

now subtract 3 from the month

and use this fm this will give the last day of the particular month

for eg

current month required

3 12 and -1 for year

4 1

5 2

like this

for

2 11 -1 for year

1 10 and -1 for year

then use it

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = R_FDATE-HIGH

IMPORTING

LAST_DAY_OF_MONTH = G_LTDT

EXCEPTIONS

DAY_IN_NO_DATE = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

regards,

Venkatesh

Former Member
0 Kudos

Use the Function module 'CCM_GO_BACK_MONTHS' ...

when u execute this function module give the Date (which date u need) and the number of months you need to go back as input parameter.... it will give u that previous date..

Former Member
0 Kudos

Hi,

chk out this link:

Hope its helpful.

<b>CCM_GO_BACK_MONTHS</b>

Former Member
0 Kudos

hi reddy,

1. use the FM

HR_JP_ADD_MONTH_TO_DATE

2. Pass -3

in the parameter IV_MONTHCOUNT

regards,

amit m.

Former Member
0 Kudos

Hi

Subtract 3 in month and validate if it is less than 1 then move it to 12 like this

Regards

Shiva

Former Member
0 Kudos

Hi Reddy,

The below code should guide you to get your work done

____________________________________________________________________

gv_to_date = sy-datum.

gv_from_date = sy-datum - 90.

SELECT-OPTIONS s_date FOR sy-datum DEFAULT gv_from_date TO gv_to_date.

____________________________________________________________________

Pl. rewards points for useful answer.

Regards.

former_member208856
Active Contributor
0 Kudos

Hi,

take the help from this code :

data : date type sy-datum, out_date type sy-datum.

date = sy-datum.

CALL FUNCTION 'J_1H_CAL_DATE_IN_INTERVAL'

EXPORTING

date = date

days = '00'

months = '03'

SIGNUM = '-'

years = '00'

IMPORTING

CALC_DATE = out_date.

write 😕 out_date.

I hope, it can help you,

Reward Points, if Helpful,

Sandeep Kaushik

Former Member
0 Kudos

Hi,

Check this FM:

HR_ECM_ADD_PERIOD_TO_DATE

Import parameters - Value

ORIG_DATE - 11.09.2007

NUM_DAYS - 00

NUM_MONTHS - 03

NUM_YEARS - 00

SIGNUM - -

Export parameters Value

RESULT_DATE - 11.06.2007

IS_OK - X

best regards,

Thangesh

messier31
Active Contributor
0 Kudos

HI,

In INITIALIZATION

set sy-datum to high.

use function module <b>RE_ADD_MONTH_TO_DATE</b>

passing date as sy-datum and months as -3

and put the result of this FM to low.

Enjoy SAP.

Pankaj Singh.

Former Member
0 Kudos

hi,

Use the Function module <b>'CCM_GO_BACK_MONTHS'</b> ...

With Rgds,

S.Barani

Former Member
0 Kudos

Hi Reddy

If you wish to use Function module which satisfy your criteria,then go for

<b>'CCM_GO_BACK_MONTHS'</b>

which ask you the current date i.e.,Sy-datum and go_back_months:000 i.e.,003

it gives you the three months prior to current date or sy-datum.

REWARD IF USEFUL...!

varma_narayana
Active Contributor
0 Kudos

Hi Reddy..

Call The FM

MONTH_PLUS_DETERMINE

Pass the Months as -3. and OLDDATE as the Date field.

Then it will return the Date before 3 months.

reward if Helpful.

Former Member
0 Kudos

Hi Reddy,

Use the below code.

SELECT-OPTIONS: s_date FOR sy-datum.

INITIALIZATION.

s_date-sign = 'I'.

s_date-option = 'BT'.

s_date-high = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = sy-datum

days = 0

months = '03'

signum = '-'

years = 0

IMPORTING

calc_date = s_date-low.

APPEND s_date.

Message was edited by:

Velangini Showry Maria Kumar Bandanadham

Former Member
0 Kudos

Hi,

You can use ' MONTH_PLUS_DETERMINE' Function module with importing Months = '3' and OLDDATE = '30.06.2007' and output u get NEWDATE as '30.09.2007' as you need.

<b>Please reward points to the helpful answers.</b>

Thanks,

Phani.