‎2007 Mar 19 10:16 PM
Hi ,
LOOP AT itab.
READ TABLE itab1 WITH KEY num = itab-NO BINARY SEARCH.
IF SY-SUBRC NE 0.
DELETE ITAB.
ENDIF.
ENDLOOP.
EVEN THOUGH THE RECORD EXIST IN ITAB1 FOR ITAB-NO SOMETIMES ITS RETURNING A SY-SUBRC NE 0.
I thought it is because of binarch search and my data in itab1 is not in a sorted order.
does that causes sy-subrc to be non-zero even though the records exist in internal table itab1
Thanks
‎2007 Mar 19 10:19 PM
Yes, it does. You must sort when you are reading a table with BINARY SEARCH.
‎2007 Mar 19 10:22 PM
‎2007 Mar 19 10:59 PM
Hi,
You need to sort ITAB, please try this.
SORT ITAB.
LOOP AT ITAB.
READ TABLE ITAB1 WITH KEY NUM = ITAB-NO BINARY SEARCH.
IF SY-SUBRC NE 0.
DELETE ITAB.
ENDIF.
ENDLOOP.
Regards,
Ferry Lianto
‎2007 Mar 19 11:56 PM
a small correction to Ferry's response.
it should be sort itab1 by .NUM.
ie the internal table must be sorted by the key field with which you READ.
~Suresh