Monday, July 23, 2007

Performance Tuning - Operation on Internal Table

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.


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.

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.


prakashlu said...

This logic is simply superb Alionzo. I used read in loop but getting index and reading nested loop is really good. Thanks for this too...

arif said...

Is it possible for more than one column / field ?


seventyros said...

For a Excellent Online Resource for SAP EP and SAP Web Dynpro ABAP, Visit Learn SAP Online

Abap Community Forums said...

You can learn more about abap at
Abap Community Forums

google said...

Excellent Online Resource for SAP EP and SAP Web Dynpro ABAP. Visit Learn SAP Online for Free

How to make WDJ Component available on SAP EP
SAP Enterprise Portal Application in NWDS
SAP and Their Produstcs - SMB Customer - SAP Business One
What is SAP ?
Architecture of SAP Business One Application
Navigation in SAP Business One
SMB Portal and its Functionality
Netweaver Administrator Day to Day Work
SAP Business Intelligence
Business Partners in SAP Business One
Continuous Stock System in SAP business one

And Many Morte Topics

David E. Jacobs said...

I appreciate your idea here. Definitely it has a good content. Thank you for imparting more of your own thoughts. Good job!

ivan koki said...

Really structured and useful
And everything is clear, thanks. I looked through some posts and must say, they are very interesting. Best regards, essay writer.

oracleR12 said...

Looking forward to learn something more from your blog, It is a nice article which is informative and useful.
Thank you.
oracle R12 training

Alex Milner said...

The blogger has shared such an interesting gallery with the readers. I believe that the people who have read the details alongside this gallery have been enlightened and will be able to improve on physical education. When I saw the title for this article, I knew that it is meant for educational purposes and that why I also chose to inform the readers on HOW TO OBTAIN AN EXCELLENT UNIVERSITY ENTRY ESSAY.