28. Use WHILE instead of a DO+EXIT-construction, as WHILE is easier to understand and faster to execute
29. If two structures are identical, use MOVE x to y, rather than MOVE-CORRESPONDING x to y
When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.
MOVE BSEG TO *BSEG.
is better than
MOVE-CORRESPONDING BSEG TO *BSEG.
30. Ensure that the first tested condition in an IF statement is most frequently true. For a logical AND statement put the most likely FALSE case first, and conversely for a logical OR statement put the most likely TRUE statement first. (But this will only lead to a noticeable performance improvement if the test is performed *very many times with a loop.
31. Ensure that instead of nested loop, parallel cursor method is used wherever possible. Parallel cursor method involves finding out the index using READ statement & searching only the relevant entries. This will give huge performance benefits. And if possible, RFC parallelization method can also be considered.
Nested loop
Loop at T1 into W1.
Loop at T2 into W2 where F1 = W1-F1.
Endloop
Endloop
Parallel cursor method
Loop at T1 into W1.
Read table T2 into W2 with key F1 = W1-F1 Binary Search.
l_index = SY-tabix.
Loop at T2 into W3 from l_index.
If W3-F1 <> W1-F1.
Exit. “ Exit inner loop when condition fails
Endif.
Endloop
Endloop
Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records.
32. In most cases, INNER JOIN is better performing than For All Entries, so it should be used first.
The set of data that can be selected with a view greatly depends on whether the view implements an inner join or an outer join. With an inner join, you only get those records which have an entry in all the tables included in the view. With an outer join, on the other hand, those records that do not have a corresponding entry in some of the tables included in the view are also selected.
And FOR ALL ENTRIES should be avoided in case a large Volume of Data is expected in the Internal Table because the Single Database Process might use the System resources more than what is top limit set by the BASIS people and hence there can be a Short Dump. In this kind of Cases, prefer using Inner Joins over For All Entries.