01-12-2005 1:41 PM
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
01-12-2005 3:17 PM
Martin,
code from Fuat Ulugay
is o.k.,
but you have to define
v_vkorg as ranges or select-options.
Andreas
01-12-2005 1:50 PM
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
01-12-2005 1:59 PM
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.
01-12-2005 3:17 PM
Martin,
code from Fuat Ulugay
is o.k.,
but you have to define
v_vkorg as ranges or select-options.
Andreas
01-12-2005 6:27 PM
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
01-12-2005 9:31 PM
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!