In development server you may not aware of performance tuning on operation on internal table, but it could become a problem when you are working on internal table containing more 10 thousand rows.

These are tips to improve your program performance.

READ Table WITH Criteria
By default, read command on internal table will read it sequentially. The binary search algorithm helps faster search of a value in an internal table. But you must sort it before use binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.


SORT TABLE BY field1.

READ TABLE table1 WITH KEY field1 = criteria1 BINARY SEARCH.
Do try it for internal table containing more than 10 thousand rows, you will find it significantly improve performance tuning.

You can apply binary search method to improve performance on nested loop.
Nested loop:

LOOP AT inttab1.
  LOOP AT inttab2 WHERE intab2-field1 = intab1-field1.
  ENDLOOP.
ENDLOOP.


Replace above code with additional binary search.


SORT inttab2 BY field1.
LOOP AT inttab1.
  READ TABLE inttab2 WITH KEY field1 = inttab1-field1 BINARY SEARCH.
  CHECK sy-subrc = 0.
  LOOP AT inttab2 FROM sy-tabix.
    IF inttab2-field1 NE inttab1-field1.
       EXIT.
    ENDIF.
  ENDLOOP.
ENDLOOP.
 
 
 
 
Serkan AKKAVAK
Computer Engineer
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com