04-18-2008 12:19 PM
Hi,
My requirement is if i enter current date, then system should return a date which is one month back date.
Is there a function module which will calculate accordingly and subtract 30 and 31 days
PLZ HELP!
04-18-2008 12:22 PM
hi use this...
parameters: date type sy-datum.
data: output type sy-datum.
output = sy-datum - 30 .
write:/ output .
regards,
venkat
04-18-2008 12:23 PM
04-18-2008 12:26 PM
Hi,
If the date field is has a data type for date, the calculation is handled automatically by the runtime. For example.
data: datum type sy-datum.
datum = sy-datum.
datum = datum - 30.
You can simply subtract 30 days from it, it will work. If will rollback thru the last month and th last year with no problem.
Or
Try the FUnction module 'CCM_GO_BACK_MONTHS'
Regards
Kiran Sure
04-18-2008 12:30 PM
Hi,
There is FM in IS-OIL. Pasting the FM code and interface. you can create your own Z FM using following details
IMPORT PARAMETERS :
1. DATE LIKE SY-DATUM.
2. MONTHS
EXPORT PARAMETERS : DATE_E LIKE SY-DATUM (pass by value checked)
Exception : DATE_ERROR
SOURCE CODE :
FUNCTION OIL_DATE_SUBTRACT_MONTH.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(DATE) LIKE SY-DATUM
*" REFERENCE(MONTHS)
*" EXPORTING
*" VALUE(DATE_E) LIKE SY-DATUM
*" EXCEPTIONS
*" DATE_ERROR
*"----
46C RL 11.03.2002 FM OIU_DATE_SUBTRACT_MONTH copied to current FM
copied from PRA to Oil Cross
data: year type i.
data: month type i.
data: month_sub type i.
data: year_sub type i.
year = date(4).
month = date+4(2).
year_sub = months div 12.
month_sub = months mod 12.
year = year - year_sub.
if month_sub >= month.
year = year - 1.
if month_sub = month.
month = 12.
else.
month = ( 12 - month_sub ) + month.
endif.
elseif month_sub > 0.
month = month - month_sub.
endif.
if year <= 0.
message e154(o0) raising date_error. "copied from 154(OIUCM)
endif.
date_e = date.
date_e(4) = year.
date_e+4(2) = month.
ENDFUNCTION.
Regards,
Mohaiyuddin
04-18-2008 12:33 PM
REPORT ychatest MESSAGE-ID zz.
data : date1 like sy-datum,
backmonths type numc3,
date2 like sy-datum.
date1 = sy-datum.
backmonths = '1'.
CALL FUNCTION 'CCM_GO_BACK_MONTHS'
EXPORTING
currdate = date1
backmonths = backmonths
IMPORTING
NEWDATE = date2.
write : / date2.
04-18-2008 12:35 PM
Hi,
data: v_curr type sy-datum,
v_next type sy-datum.
v_curr = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = v_curr
DAYS = '0'
MONTHS = '1'
SIGNUM = '-'
YEARS = '0'
IMPORTING
CALC_DATE = v_next.
write:/5 'Current date', v_curr.
write:/5 'Previous date', v_next.