2008 Jun 19 8:39 AM
how can i check "OR" condition in: Read table itab with key...
ie, Read Table itab With Key f1 = '1000' or f2 = '5000'.
pls give me the syntax............
2008 Jun 19 8:43 AM
hiii
Read Table itab With Key f1 = '1000' .
if sy-subrc NE 0.
Read Table itab With Key f1 = '5000'
endif.
reward if useful
thx
twinkal
2008 Jun 19 8:42 AM
hiiii
you can not use OR or AND in READ statement..
but you can do the same thing differently like below
Read Table itab With Key f1 = '1000' .
if sy-subrc <> 0.
Read Table itab With Key f1 = '5000'
endif.
it will give you same result as you want to get.
reward if useful
thx
twinkal
2008 Jun 19 8:42 AM
Hi
It can't do it, it needs to replace that statament with LOOP/ENDLOOP
LOOP AT ITAB WHERE F1 = '1000'
OR F2 = '5000'.
EXIT.
ENDLOOP.
If you insert the EXIT into the loop, that statament will be like READ TABLE
Max
2008 Jun 19 8:42 AM
You cant use AND and OR operators in read statement
better to use if statement
2008 Jun 19 8:43 AM
hiii
Read Table itab With Key f1 = '1000' .
if sy-subrc NE 0.
Read Table itab With Key f1 = '5000'
endif.
reward if useful
thx
twinkal
2022 Jun 27 9:59 AM
2008 Jun 19 8:43 AM
Hi,
You can use only '=' with read statement.
So it is best if you use two read statements to achieve your functionality like
Read Table itab With Key f1 = '1000' .
If sy-ssubrc eq 0.
continue with priocessing
else.
Read Table itab With Key f2 = '5000'
IF sy-subrc eq 0.
continue with priocessing
endif.
endif..
2008 Jun 19 8:43 AM
Hi,
you could use:
LOOP AT itab INTO wa WHERE f1 = '1000' OR f2 = '5000'.
* Do Something
ENDLOOP.
Regards
Mark-André
2008 Jun 19 8:44 AM
Hi Babu ,
I dont think that is possible when you use a read statement.
Regards
Arun
2022 Jun 27 9:59 AM