02-16-2007 2:55 PM
Hi,
I have problem with reading the internal with Binary search.
I have two internal tables BSAS and BSIS. In BSAS I have 1,200,000 line items and BSIS 500,000 line items. I need to delete the line items if BSIS-BELNR NE BSAS-AUGBL.
I am using the following code :
LOOP AT gt_bsas .
READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
belnr = gt_bsas-augbl
gjahr = gt_bsas-gjahr.
IF sy-subrc NE 0.
DELETE gt_bsas.
CLEAR gt_bsas.
ELSE.
-
endif.
endloop.
By this execution of the loop is taking long time. If I use the binary search it is fast but result is not correct.
Please suggest me, how to resolve this issue.
Thanks,
Sri.
02-16-2007 2:56 PM
HI Sriram,
The read statement should not be used in conjunction with the NOT EQUALS operator.
REad return one record if the ocndition matches.
There will be definitely more than ONE record for NOT EQUALS condition.
Hence it is not only taking so much time, but also is wrong usage.
REgards,
Ravi
02-16-2007 2:57 PM
hi collect the value of sy-tabix into variable
DELETE gt_bsas index v_tabix.
LOOP AT gt_bsas .
v_tabix = sy-tabix.
READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
belnr = gt_bsas-augbl
gjahr = gt_bsas-gjahr
binary search.
IF sy-subrc NE 0.
DELETE gt_bsas index v_tabix.
CLEAR gt_bsas.
ELSE.
-
endif.
endloop.
02-16-2007 2:58 PM
hi Sriram,
do this way..
data : v_tabix like sy-tabix.
sort gt_bsas by <all Key Fields>.
LOOP AT gt_bsas .
v_tabix = sy-tabix.
READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
belnr = gt_bsas-augbl
gjahr = gt_bsas-gjahr.
IF sy-subrc NE 0.
*DELETE gt_bsas.
DELETE gt_bsas index v_tabix..
CLEAR gt_bsas.
ELSE.
------------------------
endif.
endloop.
02-16-2007 3:02 PM
Try this way:
LOOP AT gt_bsas .
<b>SORT GT_BSIS BY BUKRS BELNR GJAHR.</b>
READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
belnr = gt_bsas-augbl
gjahr = gt_bsas-gjahr
<b>BINARY SEARCH.</b>
<b>IF sy-subrc eq 0.</b>
****Do Nothing.
ELSE.
<b>DELETE gt_bsas sy-tabix.</b>
CLEAR gt_bsas.
endif.
endloop.
1. Also make sure that the KEY mentioned in READ statement follows the same seqeunce of gt_bsis structure.
Thanks,
Santosh
Message was edited by:
SKJ