Application Development 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: 

Value list in a select statement !?

Former Member
0 Kudos

data: v_vkorg type string.

v_vkorg = '2000 3000'.

select *

from A004

into corresponding fields of table i_a004Tab

where kappl eq 'V '

and kschl eq 'ZPR1'

and vkorg in v_vkorg.

Gives me an error!

I need to do a value list.Howto ?

//Martin

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

Martin,

code from Fuat Ulugay

is o.k.,

but you have to define

v_vkorg as ranges or select-options.

Andreas

5 REPLIES 5

Former Member
0 Kudos

Martin

You are doing in a wrong way, it should be this:

<b>

select *

from A004

into corresponding fields of table i_a004Tab

where kappl eq 'V '

and kschl eq 'ZPR1'

and vkorg = '2000'

and vkorg = '3000' .</b>

If you wanna include all the vkorg between 2000 and 3000 the you need to declare a <b>RANGE</b> Variable.

<b>RANGES: r_vkorg FOR A004-vkorg .</b>

The Fill the Range:

<b> r_vkorg-sign = 'I'. "(I) INCLUDE - (E) Exclude

r_vkorg-option = 'BT'. "(BT) Between

r_vkorgt-low = '2000'

r_vkorgt-HIGH = '3000'.

APPEND r_vkorgt.</b>

<b>select *

from A004

into corresponding fields of table i_a004Tab

where kappl eq 'V '

and kschl eq 'ZPR1'

and vkorg IN r_vkorgt.</b>

This should work for you!

Regards,

Carlos Lerzundy

Former Member
0 Kudos

DATA:

i_a004tab TYPE TABLE OF a004 WITH HEADER LINE.

DATA:

BEGIN OF v_vkorg OCCURS 0,

sign(1),

option(2),

low LIKE a004-vkorg,

high LIKE a004-vkorg,

END OF v_vkorg.

v_vkorg-sign = 'I'.

v_vkorg-option = 'EQ'.

v_vkorg-low = '2000'.

APPEND v_vkorg.

v_vkorg-sign = 'I'.

v_vkorg-option = 'EQ'.

v_vkorg-low = '3000'.

APPEND v_vkorg.

SELECT *

FROM a004

INTO CORRESPONDING FIELDS OF TABLE i_a004tab

WHERE kappl EQ 'V '

AND kschl EQ 'ZPR1'

AND vkorg IN v_vkorg.

-


If it helps please give points.

andreas_mann3
Active Contributor
0 Kudos

Martin,

code from Fuat Ulugay

is o.k.,

but you have to define

v_vkorg as ranges or select-options.

Andreas

0 Kudos

As an alternative you could also do this without defining a range or select-option:

DATA: i_a004tab TYPE TABLE OF a004 WITH HEADER LINE.

SELECT * FROM a004

INTO CORRESPONDING FIELDS OF TABLE i_a004tab

WHERE kappl EQ 'V '

AND kschl EQ 'ZPR1'

AND vkorg IN ('1000', '2000').

Regards,

James

Former Member
0 Kudos

One extra suggestion.

The name of your internal table, i_a004Tab, suggests that the internal table structure exactly matches table a004. Since you are doing "Select *", you are reading all of the fields from the a004.

If all of that is true, then the "into corresponding fields" is unnecessary. You can code "into table i_a004Tab". When I see an "into corresponding" in a select it makes me believe that the programmer required a match up by field name because the structures were not the same.

On the flip side, I also do not recommend the use of "Select *" for performance reasons. You should specify only the fields you need - "Select field1 field2...". If you do that and keep the structure of i_a004Tab indentical to table a004, then you will need to keep the "into corresponding" part. If you really do need all of the fields, then I suggest a comment to that effect.

I also recommend defining a range as mentioned in an earlier posting.

Let us know how it goes!