‎2008 Nov 12 4:38 PM
hi,
I have a requirement to check a Date exactly 12 months back from the present day when my function module is called.
Is there a SAP standard function module to do this manipulation?
Presently i have used the following code,
LV_DATUM = SY-DATUM
LV_DATUM = LV_DATUM - 365.
The problem in the above code is not knowing the Leap year dynamically, which means it would sometimes be less than 365 days.
Regards,
Raja
‎2008 Nov 12 4:48 PM
‎2008 Nov 12 4:51 PM
just try the following (no FM is necessary):
lv_datum = sy-datum.
lv_datum(4) = lv_datum(4) - 1.
‎2008 Nov 12 4:54 PM
Hi,
Try this FM "MONTH_PLUS_DETERMINE"
Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
Regards,
Chithra
‎2008 Nov 12 5:04 PM
DATA:lv_date TYPE d.
lv_date = '20000504'.
lv_date+0(4) = lv_date+0(4) - 1.
WRITE:/ lv_date.
‎2008 Nov 12 5:28 PM
And what about if the date was '20080229' how owuld your code work in that case?
‎2008 Nov 12 5:33 PM
‎2008 Nov 12 5:48 PM
Hi MXG
check it
DATA:lv_date TYPE d.
lv_date = '20080229'. " value you gave
lv_date+0(4) = lv_date+0(4) - 1.
WRITE:/ lv_date.outoput: 02292007
‎2008 Nov 12 5:50 PM
‎2008 Nov 12 5:52 PM
date will always be stored in YYYYMMDD format in SAP, specially in debug mode and in DB level.. its just the output or the conversion routines which shows us the ouput as per system settings...
‎2008 Nov 12 5:54 PM
‎2008 Nov 12 5:55 PM
‎2008 Nov 12 5:56 PM
date - 1year is the concept and the logic works
logic is writen in SAP _ ABAP not in Visual basics chill..
‎2008 Nov 12 5:58 PM
I guess you still dont get it.
try putting date as 02/29/2007 on any SAP date field on any screen
‎2008 Nov 12 6:04 PM
‎2008 Nov 12 5:35 PM
‎2008 Nov 12 6:12 PM
FM RP_CALC_DATE_IN_INTERVAL worked fine for me
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = '02/29/2008'
days = '0'
months = '0'
signum = '-'
years = '01'
IMPORTING
calc_date = p_bsdte.
i got p_bsdte = 02/28/2007.
‎2008 Nov 13 5:07 AM
Try this too:
DATA:
l_year1 TYPE i,
l_year2 TYPE p DECIMALS 2,
l_date TYPE sy-datum.
PARAMETER: datum TYPE sy-datum.
l_year1 = datum(4) / 4.
l_year2 = datum(4) / 4.
IF l_year1 EQ l_year2.
l_date = datum - 365.
ELSE.
l_date = datum - 366.
ENDIF.