10-24-2007 3:18 PM
hi,
my requirement is to substract 3 month from the calendar month
ie., say my calendar month is 200701 then my output should be 200611
is there any function module to do this.
Thanks in advance.
10-24-2007 3:22 PM
Use FM
Subtract 3 month from date selected
CALL FUNCTION 'HR_PT_ADD_MONTH_TO_DATE'
EXPORTING
dmm_datin = date
dmm_count = 3
dmm_oper = '-' "Subtraction operator
dmm_pos = space
IMPORTING
DMM_DAOUT = lv_date
EXCEPTIONS
UNKNOWN = 1
OTHERS = 2
.
Lokesh
Please reward if post helps.
10-24-2007 3:22 PM
Use FM
Subtract 3 month from date selected
CALL FUNCTION 'HR_PT_ADD_MONTH_TO_DATE'
EXPORTING
dmm_datin = date
dmm_count = 3
dmm_oper = '-' "Subtraction operator
dmm_pos = space
IMPORTING
DMM_DAOUT = lv_date
EXCEPTIONS
UNKNOWN = 1
OTHERS = 2
.
Lokesh
Please reward if post helps.
10-24-2007 3:29 PM
thanks for ur response
actually my input is calendar month (200709) not date.
is there any function module to calulate from that
thanks.
10-24-2007 3:58 PM
I could not find any FM which adds month to period. I think the best option would be append 01 to your period and then pass it to the FM I mentioned. Then you can remove 01 from the date returned by the FM.
Hope it helps.
Lokesh
PS. Please reward helpful posts.
10-24-2007 3:22 PM
Hi,
Please use FM RP_CALC_DATE_IN_INTERVAL.
DATA: IDATE LIKE SY-DATUM,
ODATE LIKE SY-DATUM.
MOVE '20070101' TO IDATE.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = IDATE
DAYS = 0
MONTHS = 3
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = ODATE.
WRITE: ODATE(6).
Regards,
Ferry Lianto
10-24-2007 3:22 PM
Hi Lokesh,
use FM CCM_GO_BACK_MONTHS and extract year and month from the new date.
<b>Reward for helpful answers</b>
Satish
10-24-2007 3:24 PM
Hello Lokesh,
Convert the period into date ... let's say the first of day of the month.
Then use this FM 'MONTH_PLUS_DETERMINE'
Like:
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = -3 " Negative to subtract from old date, positive to add
olddate = gs_date " your date.
IMPORTING
newdate = gs_date.
Regards,
Naimesh Patel
10-24-2007 4:12 PM
i think there isn't any FM for this requirement
so you have to perform some string operation for your requirement...
use concatenate to solve your problem here..
Do something like this way...
data : urdate(6).
DATA: IDATE LIKE SY-DATUM,
ODATE LIKE SY-DATUM.
urdate = '200701'.
CONCATENATE urdate '01' INTO IDATE.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = IDATE
DAYS = 0
MONTHS = 3
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = ODATE.
WRITE: ODATE(6).
hope it will solve your problem..
Thanks & Regards
ilesh 24x7
10-25-2007 11:33 AM