‎2008 Jul 04 11:39 AM
can we use OR between primary key in READ TABLE command of abp
‎2008 Jul 04 12:03 PM
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.
‎2008 Jul 04 11:40 AM
hi,
Read table itab with key k1 k2.
thats it . No or conditions.
‎2008 Jul 04 11:41 AM
‎2008 Jul 04 11:42 AM
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>.
‎2008 Jul 04 11:44 AM
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
‎2008 Jul 04 11:44 AM
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
‎2008 Jul 04 11:44 AM
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
‎2008 Jul 04 12:03 PM
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.
‎2008 Jul 04 12:09 PM
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
‎2008 Jul 04 12:23 PM