‎2008 Apr 24 11:05 AM
i have to read a internal table with two key values for the same field.
itab contains the following records:
<f1> <f2> <f3>
val1 x x
val2 x x
val3 x x
for <f1> = val1 or val2 i want to read itab.
read table <itab>into <wa> with key <f1> =val1 or val2. this stmt doesnt work..so how can i do it?
‎2008 Apr 24 11:12 AM
Hi,
read will get u only one record at a time.
if u want to check whether the record is existing or not with both the case do like below.
read table itab with key <f1> = 'VAL1'.
if sy-subrc <> 0.
read table itab with key <f1> = 'VAL2'.
if sy-subrc = 0.
"ur logic
endif.
else.
*ur logic
endif.
rgds,
bharat.
‎2008 Apr 24 11:06 AM
hi
u cannot read the record in that way.
loop the internal table.
use if -endif condition to check the same.
regards,
madhu
‎2008 Apr 24 11:08 AM
i have to read a internal table with two key values for the same field.
itab contains the following records:
<f1> <f2> <f3>
val1 x x
val2 x x
val3 x x
for <f1> = val1 or val2 i want to read itab.
read table <itab>into <wa> with key <f1> =val1 or val2. this stmt doesnt work..so how can i do it?
u r code only excetues but small modification is needed i.e.
read table <itab>into <wa> with key <f1> =val1 or <f1> =val2.
its enough..
reward if useful
‎2008 Apr 24 11:09 AM
Hi
Try like this.
read table <itab>into <wa> with key <f1> = val1
or <f1> = val2.
Regards
Haritha.
‎2008 Apr 24 11:11 AM
Read the internal table twice ...
read table itab into wa with key f1 = val1.
if sy-subrc <> 0.
read table itab into wa with key f1 = val2.
endif.
‎2008 Apr 24 11:11 AM
Hi rakhi,
U can try this way
read table <itab>into <wa> with key (f1 =val1 or f1=val2).
reward if helpful
raam
‎2008 Apr 24 11:13 AM
i have already tried these stmts ..bt these dont works read table
<itab>into <wa> with key <f1> = val1 or <f1> = val2.
read table <itab>into <wa> with key ( <f1> = val1 or <f1> = val2).
‎2008 Apr 24 11:12 AM
Hi,
read will get u only one record at a time.
if u want to check whether the record is existing or not with both the case do like below.
read table itab with key <f1> = 'VAL1'.
if sy-subrc <> 0.
read table itab with key <f1> = 'VAL2'.
if sy-subrc = 0.
"ur logic
endif.
else.
*ur logic
endif.
rgds,
bharat.
‎2008 Apr 24 11:17 AM
hi you cannot use OR in read table.
to perform what you want you can do like tis.
read table <itab>into <wa> with key <f1> .
if sy-subrc <> 0.
read table <itab>into <wa> with key <f1> val2.
endif.
reward if useful.
‎2008 Apr 24 11:23 AM
‎2008 Apr 24 11:26 AM
How did u wrote
defenitely it should be or what i have given previously.. if it is wrong please mention how did u wrote
‎2008 Apr 24 11:35 AM
read table <itab>into <wa> with key <f1> =val1 or <f1> =val2. does not work
i have used two read stmts ie.
read table <itab>into <wa> with key <f1> =val1.
read table <itab>into <wa> with key <f1> =val2 .
Edited by: rakhi bose on Apr 24, 2008 12:37 PM