‎2019 Sep 17 7:36 PM
How can we write in read statement with one field multiple key values ...
How to write the statement can any one help
I wrote like the below code but those are not working.
1.Read table itab into wa with key = 's' or 'n'.
2.read table itab into wa with key = (' s' or 'no' )
Thanks in advance,
Shivani.
‎2019 Sep 17 7:46 PM
you can't use a single READ TABLE for this task. Try
LOOP AT WHERE condition.
EXIT.
ENDLOOP.you can check sy-subrc after the LOOP.
Also try to push this logic to your database query.
JNN
‎2019 Sep 17 8:02 PM
Hello,
You cannot write a statement as such.
Instead you can prioritize your key values, for example if you feel reading the internal with Key value S is your first priority then you can read the same. If The read is successful then proceed else read the same table again with N. Below snippet is for reference.
Read itab into WA with key field = S.
If sy-subrc eq 0.
Proceed.
Else.
Read table into wa with key field = N.
End if.
In case your priority is reversed then use the vice versa of the same as given above.
Kindly note you cannot use OR condition in read statements.
Regards
‎2019 Sep 17 8:06 PM
Hi,
I think if you search in this forum you can find the answer.
‎2019 Sep 18 4:44 PM
READ TABLE is used to process single record.
You may try with LOOP AT WHERE clause.
Previously it was done with
READ TABLE itab { { }
| { WITH KEY dobj }
| { WITH KEY = dobj } } [BINARY SEARCH] result.This is obsolete now. You can read more on Binary search and alternatives here.