Skip to Content
0
Former Member
Apr 29, 2011 at 07:04 AM

Issue with nested loop

310 Views

Hi,

There is a nested loop in the program which is causing a performance issue. The first internal table loop contains 6700 entries and the second internal table loop contains more than 5,00,000 entries. Can somebody please have a look at the below code and suggest how i can modify it to avoid the performance issue?

LOOP AT lt_zquota_item_skip INTO ls_zquota_item_val.

READ TABLE i_zquota_item2 TRANSPORTING NO FIELDS

WITH KEY product = ls_zquota_item_val-product

source = ls_zquota_item_val-source

destination = ls_zquota_item_val-destination

BINARY SEARCH.

IF sy-subrc IS INITIAL.

v_tabix = sy-tabix.

LOOP AT i_zquota_item2 INTO wa_zquota_item2 FROM v_tabix

WHERE product = ls_zquota_item_val-product

AND source = ls_zquota_item_val-source

AND destination = ls_zquota_item_val-destination.

v_tabx2 = sy-tabix.

APPEND wa_zquota_item2 TO lt_zquota_keep.

DELETE i_zquota_item2 INDEX v_tabx2.

ENDLOOP.

ENDIF.

READ TABLE i_zquota_item_val TRANSPORTING NO FIELDS

WITH KEY product = ls_zquota_item_val-product

source = ls_zquota_item_val-source

destination = ls_zquota_item_val-destination

BINARY SEARCH.

IF sy-subrc IS INITIAL.

v_tabix = sy-tabix.

LOOP AT i_zquota_item_val INTO ls_zquota_item_val FROM v_tabix

WHERE product = ls_zquota_item_val-product

AND source = ls_zquota_item_val-source

AND destination = ls_zquota_item_val-destination.

DELETE i_zquota_item_val INDEX sy-tabix.

ENDLOOP.

ENDIF.

ENDLOOP.