2009 Feb 08 7:54 AM
Hi Gurus,
I am using a variable to capture the data for Current month(Minus) 3,like the one shown below, my problem is now when i am pulling the data for last year i.e i want for 11th month from this month i get the below value for t-moth (1-/08/2009)
in debugging mode and my select query is failing. Could you help me in getting the correct month stored in the variable. Thanks in advance
DATA : v_year(4) TYPE c,
v_mon(2) TYPE c,
v_day(2) TYPE c,
t_month(10) type c.
v_year = sy-datum+0(4).
v_mon = sy-datum+4(2) - 3.
v_day = sy-datum+6(2).
CONCATENATE v_mon'/' v_day'/' v_year INTO t_month.
Best Regards
Meenakshi
2009 Feb 08 8:00 AM
>
>v_mon = sy-datum+4(2) - 3.
The above statement is being treated as a string u cant apply numerical operations to it.
2009 Feb 08 8:00 AM
>
>v_mon = sy-datum+4(2) - 3.
The above statement is being treated as a string u cant apply numerical operations to it.
2009 Feb 08 8:03 AM
use following fm insted:
RP_CALC_DATE_IN_INTERNAL
DATE_IN_FUTURE
2009 Feb 08 8:06 AM
HR_PSD_DATES_ADD_MONTHS
MONTH_PLUS_DETERMINE
these FMs will help u to achieve ur requirement.
кu03B1ятu03B9к
2009 Feb 08 8:08 AM
Hi,
Test the following Code it is working Fine.
DATA : v_year(4) TYPE c,
v_mon(2) TYPE c,
v_day(2) TYPE c,
t_month(10) TYPE c.
v_year = sy-datum+0(4).
v_mon = sy-datum+4(2).
v_day = sy-datum+6(2).
SUBTRACT 3 FROM v_mon.
IF v_mon < 1.
SUBTRACT: 1 FROM v_year.
v_mon = 12 + v_mon .
ENDIF.
Hope will solve out your problem,
Kind Regards,
Faisal
2009 Feb 08 1:17 PM
hi,
data:
w_date type sy-datum,
mnth(2) type n,
w_temp(2) type n,
w_month(2) type n.
w_month = w_date+4(2). " Current month
w_month = w_month - mnth. " Required month in the past
if w_month LT 1. " If w_month value is negative 12 is added
add 12 to w_month. " ex. current month feb, value 2, 5 months in the past
endif. " 2 - 5 = -3 + 12 = 9, i.e. september.
Do.
subtract 1 from w_date.
w_temp = w_date+4(2).
if w_month = w_temp.
exit.
endif.
enddo.
write: w_date. " last day of the required month.
Thanks
Sharath
2009 Feb 08 1:29 PM
Hi meenakshi,
You can as well use the given code to achieve this easily.
parameters : p_date like sy-datum,
p_mon(2) type n.
data : w_dummy_date like sy-datum.
start-of-selection.
w_dummy_date = p_date.
w_dummy_date+6(2) = 15. " For subtraction of month so that no discrepancy occurs even if feb
month comes
Do p_mon times.
subtract 30 from w_dummy_date. " going back 1 month from the given month.
enddo.
p_date4(2) = w_dummy_date4(2). " Changing month in the actual date parameter
p_date0(4) = w_dummy_date0(4). " changing year in the actual date parameter
day should not be changed.....
write p_date.
Hope this is helpful to you
Regards,
Siddarth
2010 Feb 02 1:51 PM