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

Read Table with condition

Former Member
0 Likes
33,217

Hi,

can i write a Read table like for example,

read table itab into wa_itab with key matnr ne '4'.

as its giving me an error.

can suggest any other way to write the Read Table statement.

Thanks in advance.

Robert

9 REPLIES 9
Read only

Former Member
0 Likes
8,757

Hi,

No it is not possible...Use Loop with Where Clause....

Read only

Former Member
0 Likes
8,756

Hi,

READ with NE is not possible.

You will have to make use of LOOP.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
8,756

in the READ TABLE statement you can ONLY compare on equality, not on differences, unequality or ranges.

for your requirement use


Loop at itab into wa where XXX. "your criterias here
endloop.

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
8,756

No. use LOOP

Read only

Former Member
0 Likes
8,756

Hi Robert,

Use Loop instead of Read statement.

Or declare itab1 like itab.

itab1[] = itab[].

delete itab1 where matnr ne '4'.

then loop it so that there will be less entries in table.

Regards,

Vijay

Read only

Former Member
8,756

Hi,

it is not possible.

try this way..


"delete the material which is not equal to 4 ..now itab contains values matnr ne4
delete table itab where matnr ne '4'. 


or

loop at itab into wa_itab wher matnr ne '4'. 
"move to another table
endloop.

or

loop at itab into wa_itab .
if wa_itab-matnr ne '4'. 
 continue
"move to another table
else.
  delete itab index sy-tabix.
endif.
endloop.


prabhudas

Read only

Former Member
0 Likes
8,756

Hi,

If matnr = '4', then you can write the read statement as

Read table itab into wa_itab with key matnr = '4'.

if matnr NE 4, then you may be having more than one record in itab, then read statement can't be used. Read statement can read only one record from itab. then you have to use Loop and endloop.

loop at itab into wa_itab where matnr = '4'.

-


-


endloop.

Hope this is helpful.

Regards

Ramesh.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
8,756

read table itab into wa_itab with key matnr ne '4'. "not possible

read table itab into wa_itab with key matnr eq '4'. "not possible

read table itab into wa_itab with key matnr = '4'. "Possible

Read only

Former Member
0 Likes
8,756

Please press F1 on Read before posting basic questions - thread locked.

And please do not answer these sorts of questions.

Rob

Edited by: Rob Burbank on Jul 9, 2009 9:30 AM