Skip to Content
author's profile photo Former Member
Former Member

Value list in a select statement !?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jan 12, 2005 at 03:17 PM

    Martin,

    code from Fuat Ulugay

    is o.k.,

    but you have to define

    v_vkorg as ranges or select-options.

    Andreas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2005 at 01: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 09: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!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.