01-20-2006 2:07 PM
Hi All,
I need to read an internaltable itab where column col1 not equal to 'XXX'.
my statment will be
read table itab with key col1 ne 'XXXX'.
since this is not working,
how can i write this statement.
Thanks in Advance
Arun
01-20-2006 2:10 PM
IF you are pretty sure that there will be only one record then do this:
LOOP AT itab INTO wa WHERE col1 NE 'XXX'
EXIT.
ENDLOOP.
Regards,
Srikanth
01-20-2006 2:11 PM
HI Arun,
1. Loop At ITAB.
Use this kind of syntax(logic)
instead of READ.
2. Bcos
READ will return only 1 record.
3. eg.
report abc.
data : t001 like table of t001 with header line.
select * from t001
into table t001.
break-point.
loop at t001 where bukrs <> '1000'.
endloop.
regards,
amit m.
01-20-2006 2:15 PM
hi arun,
read table will give only one record, so you can use..
loop at itab where col1 <> vlaue.
"after doing what ever you want..
exit.
endloop.
regards
vijay
01-20-2006 2:18 PM
Dear All,
In mY program I have 2 internal tables.
loop at itab1.
read itab with key col2 = itab1-col2 col1 ne 'XXXX'.
endloop.
Thanks in Advance
Arun
01-20-2006 2:21 PM
Hi again,
1. Here also u can use second loop (preferable to read)
2.
loop at itab1.
loop at itab2 where col2 = itab1-cols and col1 <> 'XXXX'.
endloop
endloop.
regards,
amit m.
01-20-2006 2:32 PM
loop at itab1.
loop at itab where col2 = itab1-col2
and col1 ne 'XXXX'.
"do required stuff..
exit.
endloop.
endloop.
01-20-2006 2:36 PM
Hi Arun,
Read statement does not take NE.You have to use loop & where condition.
01-20-2006 4:16 PM
If both internal tables are large, then the nested looping will be slow. This should be faster:
LOOP AT itab1.
* Get the first matching record
READ TABLE itab
WITH KEY col1 = itab1-col1
BINARY SEARCH.
IF itab-col2 <> 'XXXX'.
* Process the record
ENDIF.
itab_index = sy-tabix.
WHILE sy-subrc = 0.
itab_index = itab_index + 1.
* Get subsequent matching records
READ TABLE itab INDEX itab_index.
IF sy-subrc = 0 AND
itab-col1 = itab1-col1.
IF itab-col2 <> 'XXXX'.
* Process the record
ENDIF.
ELSE.
* No matching records or end of internal table
sy-subrc = 99.
ENDIF.
ENDWHILE.
ENDLOOP.
If one or both tables are small, then it won't make much difference.
Rob
01-20-2006 2:35 PM
Hi,
Read table doen't allow ne operator.
try using loop at itab where var <> 'xxx'.
Regards
Amole