‎2006 Dec 28 12:44 PM
hi guys,
i have a parameter of type DATE in selection screen.
i will capture its month in some variable, say VAR = 12.
i want to select all the entries from all the months. till the month i selected in selection screen.
suppose i select the date 12.12.1995 it should select all the entries of this month and go back to january select all the entries, then in february select all the entries and so on till........ november i.e the month i selected - one. (12-1)
i have written this query
SELECT * FROM tcurr INTO TABLE wt_tcurr
WHERE kurst = '1001' AND
gdatu = ' <b>what should i give here</b> '.
how will i get the month dynamically one after other.
please reply
ahmed
‎2006 Dec 28 12:49 PM
Hi,
Please use ranges in where clause and IN operator
Plz use the following code.
data:
r_date type range of sydatum,
wa_date type line of r_date.
data:
lv_input type sydatum,
lv_input1 type sydatum,
lv_tdate type sydatum,
lv_fdate type sydatum.
lv_input = '20051212'.
concatenate lv_input+0(4) '01' '01' into lv_tdate .
lv_input1 = lv_input+0(4) - 1.
*call method CL_RECA_DATE=>GET_DATE_INFO. by passing lv_input+4(2).
concatenate lv_input+0(4) '31' '01' into lv_fdate .
wa_date-option = 'BT'
wa_date-SIGN = 'I'
wa_date-HIGH = lv_tdate.
wa_date-LOW = lv_fdate.
append wa_date to r_date.SELECT * FROM tcurr INTO TABLE wt_tcurr
WHERE kurst = '1001' AND
gdatu <b>IN r_date</b>
Regards
Bhupal Reddy
‎2006 Dec 28 12:57 PM
Hi Ahmed,
This will do the trick,
REPORT zkb_test5.
PARAMETERS: p_bdate TYPE s_bdate.
DATA: i_sbook TYPE TABLE OF sbook,
w_sbook TYPE sbook.
DATA: v_date TYPE sy-datum.
START-OF-SELECTION.
v_date+4(4) = '0101'. " From 1 st Jan (Put your date here)
v_date(4) = p_bdate(4). " Move Year
SELECT * FROM sbook INTO TABLE i_sbook
WHERE order_date GE v_date
AND order_date LE p_bdate.
LOOP AT i_sbook INTO w_sbook.
WRITE: / w_sbook-bookid, ' / ', w_sbook-order_date.
ENDLOOP.
Regards
Kathirvel
‎2006 Dec 28 1:04 PM
date is stores as 19951212 in SAP.
so, do this way...
V1 = 12
V2 = 12
V3 =1995
do 12 times.
concatenate V3 V2 V1 into date.
SELECT * FROM tcurr appending TABLE wt_tcurr
WHERE kurst = '1001' AND
gdatu = date.
V2 = V2 - 1.
enddo.