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: 

Where condition

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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

0 Kudos

Hello Siva,

Now it is showing an error

The IN operator with "P_BUKRS" is followed neither by an internal table nor by a value list.

Best Regards,

Aastha

0 Kudos

hi,

do this way ...

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.

0 Kudos

Hi,

The error is because you have decalred p_bukrs as parameter. Convert this to range tables and then use in your select query.

0 Kudos

Hello Santosh,

It's not working.

Plz tell me, some other way

best Regards,

Aastha

0 Kudos

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.

Former Member
0 Kudos

Hi,

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

Shruthi

Former Member
0 Kudos

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