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

unable to interpret

Former Member
0 Likes
3,850

hello friends,

i was trying to execute the following .

read table itab1 with key name NE 'A'.

if sy-subrc = 0.

write:/ ' error'.

endif.

it says " Unable to interpret 'NE'. possible causes of error : incorrect spelling.

can any one tell what my mistake is.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,558

Hi,

Yes, you need to use LOOP statement.


LOOP AT ITAB1 WHERE NAME NE 'A'.
  WRITE: / 'ERROR'.
  EXIT.
ENDLOOP.

Regards,

Ferry Lianto

Hi,

Yes, you need to use LOOP statement.


LOOP AT ITAB1 WHERE NAME NE 'A'.
  WRITE: / 'ERROR'.
  EXIT.
ENDLOOP.

Regards,

Ferry Lianto

6 REPLIES 6
Read only

Former Member
0 Likes
2,558

You should not use ne operator in read table command,always you should use =

Read only

Former Member
0 Likes
2,558

Hi Sarita,

do this

read table itab1 with key name Eq 'A'.

if sy-subrc ne 0.

write:/ ' error'.

endif.

Thanks

Venki

Read only

Former Member
0 Likes
2,558

then how should i do if ,

i have to report error if name field has an entry other than 'A'.

cant i do that using read, if not then i have to use loop at.

Read only

0 Likes
2,558

Hello Saritha,

i have two internal table..

data : begin of i_jtab occurs 0,

empno like ztable-empno,

loc like ztable-loc,

end of i_jtab.

data : begin of itab1 occurs 0,

empno like ztable1-empno,

name like ztable1-name,

end of itab1.

let assume you have data in both internal table

loop at i_jtab.

read table itab1 with key empno = i_jtab-empno.

if sy-subrc eq 0.

if itab1-name = 'A'.

write:/ 'Error'.

endif.

endif.

endloop.

You should not use NE Condition in Read table and it will not support,so use = and then keep IF Condition below.

Read only

Former Member
0 Likes
2,559

Hi,

Yes, you need to use LOOP statement.


LOOP AT ITAB1 WHERE NAME NE 'A'.
  WRITE: / 'ERROR'.
  EXIT.
ENDLOOP.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
2,558

i understood,

thanks ferry, and sheshu