Advertisements
So is it possible to add an OR condition to the key values of the read statement? The simple answer is no, but you can replicate this functionality using one of two methods.
Method 1 - Using multiple ABAP READ statements within nested IF statements
Advertisements
The first method would be to use multiple READ statements to check each condition but nest these within IF statements.
i.e. Read condition 1
if no entry found read condition 2
if no entry found read condition 3 etc etc
Advertisements
Method 2 - Using an ABAP LOOP statement
Advertisements
The second method would be to use a LOOP statement with all the options within the where clause and simply EXIT on the first loop pass.
i.e.LOOP at itab where condition 1 or condition 2.
EXIT.
ENDLOOP.
If sy-subrc eq 0.
"Data found
endif.
data: IT_COMPONENT type standard table of SEOCOMPO, WA_COMPONENT like line of IT_COMPONENT. select * from SEOCOMPO as A inner join SEOCOMPOTX as B on B~CLSNAME = A~CLSNAME and B~CMPNAME = A~CMPNAME inner join SEOCOMPODF as C on C~CLSNAME = A~CLSNAME and C~CMPNAME = A~CMPNAME into corresponding fields of table IT_COMPONENT where A~CMPTYPE in (0,1,2) and B~LANGU eq SY-LANGU. sort IT_COMPONENT by clsname cmptype. "READ solution read table IT_COMPONENT transporting no fields with key CLSNAME = WA_CLASS-CLSNAME CMPTYPE = 0 binary search. if SY-SUBRC eq 0. "perform entry_found. else. read table IT_COMPONENT transporting no fields with key CLSNAME = WA_CLASS-CLSNAME CMPTYPE = 1 binary search. if SY-SUBRC eq 0. "perform entry_found. else. EXIT. endif. endif. "loop solution LOOP at IT_COMPONENT into WA_COMPONENT where CLSNAME = WA_CLASS-CLSNAME AND ( CMPTYPE = 0 or CMPTYPE = 1 ). ENDLOOP. if sy-subrc eq 0. "at least one entry found else. EXIT. endif.