Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

multiple selection values variable in select statement..help needed

Former Member
0 Likes
2,262

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

7 REPLIES 7
Read only

Former Member
0 Likes
1,036

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

Read only

Former Member
0 Likes
1,036

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

....

Read only

Former Member
0 Likes
1,036

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.

Read only

Former Member
0 Likes
1,036

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

Read only

Former Member
0 Likes
1,036

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

Read only

Former Member
0 Likes
1,036

<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>

Read only

Former Member
0 Likes
1,036

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>