‎2006 Nov 20 2:51 PM
hello everyone,
i have a select statement where i have multiple values for one field.....
like as below
select .........
........
.........
fields...
.......
........
from 'table'
where ERR_MSG = HERE FOR THIS FIELD I HAVE MULTIPLE VALUES.
now i want all the data from table in which these values are there.
please, can anyone help me........
thanks in advance
‎2006 Nov 20 2:54 PM
Hi,
Just declare a ranges field. Fill ur values in ranges and in where clause pass this as,
where err_msg in <declared range>
ex:
ranges : range1 for CHAR10.
range1-sign = 'I'.
range1-option = 'EQ'.
range1-low = 'Err VAlue'1.
append range1.
clear Range 1.
range1-sign = 'I'.
range1-option = 'EQ'.
range1-low = 'Err VAlue2'.
append range1.
clear Range 1.
.
.
.
.
In where clause give,
where err_msg in range1.
Sreedhar
‎2006 Nov 20 2:54 PM
create a range for this field ERR_MSG and populate all the applicable values. Then use that range in select statement.
....
where ERR_MSG IN r_err_msg
....
‎2006 Nov 20 2:55 PM
Hi ganesh,
1. now i want all the data from table in which these values are there.
and then use FOR ALL ENTRIES.
Put all these values, in one internal table.
2. use this sample program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
3
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*----
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*----
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*----
LOOP AT t001.
WRITE 😕 t001-bukrs.
ENDLOOP.
regards,
amit m.
‎2006 Nov 20 2:55 PM
Ganesh,
Try this
where field in ('1', '2', '3').
or take a range variable.
append all the values into that variable
where field in r_field.
-Anu
‎2006 Nov 20 2:55 PM
Hi,
you can declare a variable as ranges. and use the same as select-options.
the syntax is
ranges: a type vbrk-vbeln.
u can use this in the select staements.
for mor details.
http://help.sap.com/saphelp_47x200/helpdata/en/18/a1f251e28b11d295f500a0c929b3c3/frameset.htm
‎2006 Nov 20 2:55 PM
<b>ranges: r_errmsg for <table>-err_msg.
*fill the ranges from the multiple values you have(Assuming that you have them in an itab).
loop at itabe.
r_errmsg-low = itab-msg.
r_errmsg-sign = 'I'.
r_errmsg-option = 'EQ'.
append r_errmsg.
endloop.</b>
select .........
........
.........
fields...
.......
........
from 'table'
where ERR_MSG <b>in r_errmsg.</b>
‎2006 Nov 20 2:57 PM
hi,
declare one range for that field and use
data : begin of r_errors occurs 0,
sign(1),
option(2),
low like ztable-err_msg,
high like ztable-err_msg,
end of r_errors.
r_errors-low-sign = 'I'.
r_errors-option = 'BT'.
r_errors-low = 'Error message 1'. " specify ur error message her
r_errors-high = ''.
append r_errors.
clear r_errors-low.
r_errors-low-sign = 'I'.
r_errors-option = 'BT'.
r_errors-low = 'Error message 2'.
r_errors-high = ''.
append r_errors.
clear r_errors-low.
select .........
........
.........
fields...
.......
........
from 'table'
where ERR_MSG<b> in r_errors.</b>