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

Select-statement with IN

Former Member
0 Likes
320

Hi everybody,

I have a number (several thousands) of single values. This values must be inserted into the table lt_singelvalues. Now i want to use a SELECT statement with "IN" like the following example in order to get only values within lt_singlevalues:



  SELECT * from mytable INTO lt_mytable 
     WHERE value IN lt_singlevalues

How can i create a table like lt_singlevalues in order to use "WHERE value IN lt_singlevalues"?

regards,

sid

Edited by: Sid on Jul 7, 2009 8:46 PM

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
290

You may define the table like this. But be advised there is a limitation to the number of single values that you can add to the table and use in the IN operator of a SELECT statement. The only work around for this is to use a RANGE between set numbers or incorporate an exclusion as well. I think the limit is between 750 and 900.

Types: Begin of t_sv,
              sign(1) type c,
              option(2) type c,
              low(20) type c,
              high(20) type c,
            end of t_sv.
data: lt_singlevalues type table of t_sv.
data: ls_singlevalues like line of lt_singlevalues.


ls_singlevalues-sign = 'I'.
ls_singlevalues-option = 'EQ'.
ls_singlevalues-low = '1000'.
append ls_singlevalues to t_singlevalues.
ls_singlevalues-low = '2000'.
append ls_singlevalues to t_singlevalues.
ls_singlevalues-low = 3000'.
append ls_singlevalues to t_singlevalues.

Also, the LOW and HIGH fields can be a specific type, like if you needed the length to be 30, you can modifiy it, but the SIGN and OPTION fields must be char 1, and char 2 fields respecfully.

Regads,

Rich Heilman

Edited by: Rich Heilman on Jul 7, 2009 2:52 PM

2 REPLIES 2
Read only

Former Member
0 Likes
290

Have you tried it?

Rob

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
291

You may define the table like this. But be advised there is a limitation to the number of single values that you can add to the table and use in the IN operator of a SELECT statement. The only work around for this is to use a RANGE between set numbers or incorporate an exclusion as well. I think the limit is between 750 and 900.

Types: Begin of t_sv,
              sign(1) type c,
              option(2) type c,
              low(20) type c,
              high(20) type c,
            end of t_sv.
data: lt_singlevalues type table of t_sv.
data: ls_singlevalues like line of lt_singlevalues.


ls_singlevalues-sign = 'I'.
ls_singlevalues-option = 'EQ'.
ls_singlevalues-low = '1000'.
append ls_singlevalues to t_singlevalues.
ls_singlevalues-low = '2000'.
append ls_singlevalues to t_singlevalues.
ls_singlevalues-low = 3000'.
append ls_singlevalues to t_singlevalues.

Also, the LOW and HIGH fields can be a specific type, like if you needed the length to be 30, you can modifiy it, but the SIGN and OPTION fields must be char 1, and char 2 fields respecfully.

Regads,

Rich Heilman

Edited by: Rich Heilman on Jul 7, 2009 2:52 PM