11-03-2009 10:02 AM
Hi,
I have 2 tables :
WT_TABLE1
INTRENO | OBJNR
0001 | IS001
0002 | IS002
0003 | IS003
0004 | IS004
0005 | IS001
WT_TABLE2
0001 | IS001
0003 | IS003
I want detele entries in WT_TABLE1 who is not in table WT_TABLE2.
I have a code that work but i need to know if they are instruction with better performance?
LOOP AT WT_TABLE1 into WS_TABLE1
READ TABLE WT_TABLE2 INTO WS_TABLE2
WITH KEY OBJNR = WS_TABLE1-OBJNR.
if sy-subrc <> '0'.
delete wt_contrat.
endif.
ENDLOOP.
Thank you for your reply.
Spawntae
11-03-2009 10:04 AM
Hi,
This will work fine w/t performance issue.
Regards,
Dhan
11-03-2009 10:04 AM
Hi,
This will work fine w/t performance issue.
Regards,
Dhan
11-03-2009 11:53 AM
11-03-2009 1:06 PM
Hi It wont affect but change the code as below :-
clear : ws_table1,
ws_table2.
Sort wt_table1 by intreno objnr.
LOOP AT wt_table1 INTO ws_table1.
READ TABLE wt_table2 INTO ws_table2
WITH KEY intreno = ws_table1-intreno
objnr = ws_table1-objnr.
IF sy-subrc NE 0.
DELETE table wt_table1 from ws_table1.
ENDIF.
ENDLOOP.
11-03-2009 2:31 PM
... here everything is wrong, question and answers!
if sy-subrc '0'.
delete wt_contrat.
endif.
???? 2 big bugs !!!, there is wt_contract ! and what is between subrc and 0 ????
* table 2 must be sorted not 1 !!!!
SORT wt_table2 BY objnr.
LOOP AT WT_TABLE1 INTO wa1.
tabix1 = sy-tabix.
READ TABLE WT_TABLE2
TRANSPORTING NO FIELDS
WITH KEY OBJNR = wa1-OBJNR
BINARY SEARCH.
IF sy-subrc <> 0.
DELETE wt_table1 INDEX tabix1.
ENDIF.
ENDLOOP.
ENDLOOP.