LOOP AT WHERE. Vs LOOP.IF. in ABAP

At first sight, both the statements ( loop at itab where <key> = <val> ;   loop at itab. if <key> = <val>. ) looks like performing the same task.

But when it comes to performance, both beats each other in there own domain.

It all comes down to number of “‘matches” in the WHERE/IF-clause.

In case you have a rare match, the WHERE-method is better.
In case you have an always match, the IF-method is better.

When the match was done on 1-out-1000:

match ratio: 1 - out of - 1000
match ratio: 1 – out of – 1000

When the match was done at 1 – out of -2 :

match ratio: 1 - out of - 2
match ratio: 1 – out of – 2

and when the “match” is matching every line

Match ratio : matching every line
Match ratio : matching every line

 

*source = Harry Dietz

You might also be interested in these posts:

  1. Best way to Loop At ‘Standard’ Internal Table in ABAP
  2. ABAP Program to show My Inactive Programs
  3. Create a TCODE for an ABAP Query
  4. Pretty Report Vs Pretty Printer in ABAP
  5. ABAP Program to Hide Source Code of a Program

One Response to “LOOP AT WHERE. Vs LOOP.IF. in ABAP”
kalyan Posted on July 24, 2009 at 1:44 PM

Interesting. Good comparison. Thanks.

Post a Comment