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

Where condition

Hi all,

My 2nd select query is not working.

Plz tell where i m wrong.

if itab_lfa1[] is not initial.

if p_bukrs is initial.

select lifnr bukrs

from lfb1

into corresponding fields of table i_lfb1

for all entries in itab_lfa1

where lifnr = itab_lfa1-lifnr.

else.

select lifnr bukrs

from lfb1

into corresponding fields of table i_lfb1

for all entries in itab_lfa1

where lifnr = i_lfa1-lifnr

and bukrs eq p_bukrs.

endif.

endif.

Showing the error msg in 2nd select this:

The WHERE condition does not refer to the FOR ALL ENTRIES table.

But when we remove for all entries in itab_lfa1,

then it show no error, but doesn,t able to pick all records.

Best Regards,

Aastha.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 04:07 AM

    hi try this,

    select lifnr bukrs

    from lfb1

    into corresponding fields of table i_lfb1

    for all entries in itab_lfa1

    where lifnr = i_lfa1-lifnr

    and bukrs in p_bukrs.

    regards

    siva

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      Check out in this way ..

      call function 'CONVERSION_EXIT_ALPHA_INPUT'

      exporting

      input = p_bukrs

      importing

      output = p_bukrs.

      loop at itab_lfa1.

      call function 'CONVERSION_EXIT_ALPHA_INPUT'

      exporting

      input = itab_lfa1-lifnr

      importing

      output = itab_lfa1-lifnr.

      modify itab_lfa1 index sy-tabix.

      endloop.

      if not itab_lfa1[] is initial.

      select lifnr bukrs

      from lfb1

      into corresponding fields of table i_lfb1

      for all entries in itab_lfa1

      where lifnr = itab_lfa1-lifnr

      and bukrs = p_bukrs. " Assuming p_bukrs is declared as parameter

      endif.

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 04:12 AM

    Hi,

    If P_bukrs is a parameter, the convert this to select-options and use IN operator in your select statement.

    Shruthi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 04:38 AM

    Hi,

    i think you should write your second query like this....

    **********************

    select lifnr bukrs

    from lfb1

    into corresponding fields of table i_lfb1

    for all entries in itab_lfa1

    where lifnr = itab_lfa1-lifnr

    and bukrs eq p_bukrs.

    To use the for all entries you have to use it in where condition as well...

    You are using i_lfa1-lifnr in where clause by giving for all entries on itab_lfa1 table, so it wont work like that...

    You have to use atleast one filed of itab_lfa1 table in the where clause...

    check the code in bold characters.

    Reward if helpful.

    Regards,

    Syed

    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.