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

Function module required to subtract month from a date

Former Member
0 Likes
23,248

I have a date field..

In that I want to subtract some months..

Date1 = 27.05.2007

Month = 3 months

Date2 = 27.02.2007

Help me to proceed this logic with function module.

...What is the function module to get this liogic.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
8,303

Hi!

Use this Function Module

MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.

Subtract the months u want ..........

regards........

9 REPLIES 9
Read only

Former Member
0 Likes
8,303

Hi,

I don't think any FM available for your purposes.

But you can try something like this.

DATA: BEGIN OF ITAB OCCURS 0,

SPMON TYPE UMC_Y_VALIDFR,

END OF ITAB.

PARAMETERS PSPMON TYPE UMC_Y_VALIDFR DEFAULT '2007004'.

START-OF-SELECTION.

ITAB-SPMON = PSPMON.

DO 12 TIMES.

IF ITAB-SPMON+4(3) = '000'.

ITAB-SPMON+4(3) = '012'.

ITAB-SPMON(4) = ITAB-SPMON(4) - 1.

ENDIF.

APPEND ITAB.

ITAB-SPMON = ITAB-SPMON - 1.

ENDDO.

READ TABLE ITAB INDEX 12.

WRITE: / ITAB-SPMON.

Kishi.

Read only

Former Member
8,303

chk this

<b>RP_CALC_DATE_IN_INTERVAL</b>

Read only

0 Likes
8,303

This function works for this cenario.

Read only

Former Member
0 Likes
8,303

HR_PT_ADD_MONTH_TO_DATE

Read only

8,303
also chk this

REPORT abc MESSAGE-ID zz.

DATA : currdate LIKE sy-datum,
       backmonths(3) TYPE n,
       newdate LIKE sy-datum.

currdate = sy-datum.
backmonths = '3'.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'
  EXPORTING
    currdate   = currdate
    backmonths = backmonths
  IMPORTING
    newdate    = newdate.


WRITE : newdate.
Read only

Former Member
0 Likes
8,303

I have got the solution

Read only

Former Member
8,303

hi,

USE fm CCM_GO_BACK_MONTHS

Thanks

Sandeep

Reward if helpful

Read only

Former Member
0 Likes
8,304

Hi!

Use this Function Module

MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.

Subtract the months u want ..........

regards........

Read only

Former Member
0 Likes
8,303

even by that you can extract the value required.

You can also use one more function module OIL_DATE_SUBTRACT_MONTH.