Application Development and Automation 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: 
Read only

report

Former Member
0 Likes
995

can we use OR between primary key in READ TABLE command of abp

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
977

You cannot use OR with the READ Statement. it wll give Syntax error.

If you want to read an internal table sunch that f1 = 'A' or f2 ='B' then check the code below.

Clear flag.
read table itab with key f1 ='A'.
if sy-subrc <> 0.
   read table itab with key f2 = 'B'.
   if sy-subrc = 0.
    flag = 'X'.
   endif.
else.
  flag = 'X'.
endif.
If flag = 'X'.
* Do your processing.
endif.

reward if useful.

9 REPLIES 9
Read only

Former Member
0 Likes
977

hi,

Read table itab with key k1 k2.

thats it . No or conditions.

Read only

Former Member
0 Likes
977

you can not use OR

Read only

Former Member
0 Likes
977

you can't use anything else apart from '=' in the READ table statement. Even 'EQ' is not allowed..

read table itab with key <field> = <value>.

Read only

Former Member
0 Likes
977

hi,

There is no way that we can specify an OR condition with Primary Key of the Table.

We can read in this way:

READ TABLE itab WITH TABLE KEY k1 = <value>

Hope this will help.

Reward if helpful.

Sumit Agarwal

Read only

bpawanchand
Active Contributor
0 Likes
977

Hi

No you cannot use it

check out this code buddy

TABLES :

spfli.

DATA :

t_tab LIKE TABLE OF spfli.

SELECT

carrid connid FROM spfli INTO CORRESPONDING FIELDS OF TABLE t_tab.

READ TABLE t_tab INTO spfli WITH KEY carrid = 'AA' or carrid = 'UA'.

Regards

Pavan

Read only

Former Member
0 Likes
977

Hi Anurag,

We cannot use OR between primary key in READ statement.

The READ statement look like this:

READ TABLE itab WITH TABLE KEY k1 = f1 ... kn = fn

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
978

You cannot use OR with the READ Statement. it wll give Syntax error.

If you want to read an internal table sunch that f1 = 'A' or f2 ='B' then check the code below.

Clear flag.
read table itab with key f1 ='A'.
if sy-subrc <> 0.
   read table itab with key f2 = 'B'.
   if sy-subrc = 0.
    flag = 'X'.
   endif.
else.
  flag = 'X'.
endif.
If flag = 'X'.
* Do your processing.
endif.

reward if useful.

Read only

Former Member
0 Likes
977

Directly Noooooooooo, u cannt use. But u can do like using two read staement and setting a flag.

read table itab with key f1 ='A'.

if sy-subrc = 0.

flag = 'X'.

endif.

read table itab with key f2 ='X'.

if sy-subrc = 0.

flag = 'X'.

endif.

NOw CHECK the value of flag nd do the coding

Hope this ll be helpful.

Thanks & Regards

vinsee

Read only

Former Member
0 Likes
977

Hi,

No, you cannot OR in Read statement.

THanks,

Sriram POnna.