For demo, we will set two breakpoints: one before starting the FM and one after FM.
When we reach at the breakpoint and we try to start the performance measurement by option Utilities > Runtime Analysis > Switch On, system would give the message as "The Particular units" option is not selected.
This message appears because the DEFAULT variant doesn't have this option selected. You can see this variant in SE30. Enter the DEFAULT and press the "Display" button.
So, we need to select the option "Particular Units" in the measurement variant. To do this, we will copy this standard measurement variant to user specific variant and then select the option "Particular Units".
To measure the performance:
1) Run SE30
2) Select this newly copied variant. Here we need to select User Defined variant.
3) Enter the required program / transaction and measure it
4) When it reaches to the breakpoint ON the measurement by System > Utilities > Runtime Analysis > Switch On
5) Press F8
6) When it reaches to the next breakpoint ON the measurement by System > Utilities > Runtime Analysis > Switch Off
7) After finishing the entire transaction, press the evaluate button to evaluate the performance of required code lines.
Runtime performance can be switched ON by enter /RON in the transaction box when it reaches to the desired breakpoint. Same way /ROFF could be used to switch off the performance measurement.
Use of Field-symbols vs Work area
To use the Field-symbols against the Work Area for Internal table processing
Internal table processing is essential part of any ABAP program. Generally, we use the explicit work area to process the internal table like appending & modifying records. We can reduce the time and improve the performance of the program by using the field-symbols.
When we use the LOOP construct with the explicit work area, system need to engage the resources to put the required record in the work area, process it and move it back to the table if the needed. This additional processing time could be saved by using the field-symbol. By using the field-symbols we can save this additional time and improve the performance. Field-symbols are similar to dereferenced pointers in C. While using the field-symbol, system uses the same memory allocated to that particular field in the record instead of moving it to work area and processing. More on field-symbols can be found at: Field-Symbols on SAP Help.
This code snippet shows how to use the field-symbols to process the loop with time measurement.
In this performance measurement, time taken by the work area to process is considered as the 100%. By using the field-symbols, we can definitely improve the performance.
Parallel Cursor - 2: without using READ
Parallel Cursor without using READ
In previous post Parallel Cursor - To speed up performance of Nested LOOP, we have seen a technique how to speed up the performance of the nested LOOP constructs in ABAP. In today's post, we will see another variance of the Parallel cursor technique. In this technique, we will exit out the inner LOOP when both keys are not matching by saving the LOOP index in a variable. This index variable would be used in the LOOP construct to start the LOOP. Initially, this index variable would be set to 1. Statistics shows that this new technique is powerful over the technique as shown in the previous post which uses the READ TABLE.
Here is the code snippet to achieve this Parallel Cursor technique:
This statistics and graph shows the time used by the nested LOOP as the 100%. For the 1000 VBAK records, parallel cursor technique with READ consumes 1.84% time compare to nested LOOPs 100%. This technique without READ TABLE only requires 1.05% time compare to 100% of nested LOOPs.
Parallel Cursor - To speed up performance of Nested LOOP
Technique to speed up the performance of the Nested LOOP - Parllel Cursor
I'm back after a long break. Today, we will tackle down the biggest performance related issue around the Nested Loops.
Traditionally in ABAP, we use the LOOP using the WHERE clause for Nested loops. This type of nested loops are very common in our day-to-day programming. But, the cost, in terms of performance, is higher when we use the nested loops. This cost would become a key issue when working with huge tables e.g. BKPF & BSEG, VBAK & VBAP, MKPF & MSEG. Sometimes, this cost increases and reaches to the point where program fails to finish the execution.
We have the concept of Parallel Cursor exists in ABAP to overcome this hurdle and reduce this cost. In parallel cursor, we first try to see if there is any entry exist in the second table inside the LOOP construct of first table. We use the READ .. WITH KEY .. BINARY SEARCH to check if the entry exist in the second table. We use this record number SY-TABIX to LOOP on the second table using LOOP .. FROM index.
This code snippet gives us the idea of the time taken by both the nested loops and the parallel cursor loops.
I ran this program multiple times and capture this statistics.