Last year, I conducted performance training and started to perform tuning on programs that occupy serious system resources. The results were good! I have a tuning program that needs to run for more than 20 hours before tuning. After tuning is completed, it only takes 3-4 hours. The user is very satisfied. I am very proud of it, haha! If you are free today, record some ABAP tuning methods as follows:
I. Try to avoid using the practical method of select... endselect while using internal table.
2. Do not nest select in the loop. you can first place the Select Content in the internal table using the for all entry in method, then sort the table, and finally use read table in the loop .... with key... binary Search Method. (This method has an exception. In the case of a large amount of data in the outer loop, if the nested SELECT statement in the loop reads several data records read-only each time, when the for all entry in method is used to read a large amount of data, the read Table binary seach method may cause insufficient memory and thus dump. This conclusion is unconfirmed. The colleague concluded that the loop table contains more than 1 million pieces of data, and only a few pieces of data are read each time during the Select Operation in the loop, when the for all entry in is used, millions of data records are read, resulting in insufficient memory. My opinion: in this case, you can test and compare the two cases)
Iii. Try to use the primary key or index when using select to read table data. How can I determine whether the index works? I will talk about it later.
4. Avoid nested Delete table where in loop or loop .... You can use field symbols to solve this problem. This trick is very useful in practical applications. For more information, see the following code:
Loop at itab.
Delete itab1 where matnr = itab-matnr and
Vbeln = itab-vbeln and
Posnr = itab-posnr.
Endloop.
Recommendation:
Field-Symbols <FS> like line of itab.
Field-Symbols <fs1> like line of itab1.
Loop at itab assigning <FS>.
Read Table itab1 transporting no fields binary search
Key matnr = <FS>-matnr
Vbeln = <FS>-vbeln
Posnr = <FS>-posnr.
Lf_from_index = sy-tabix.
If sy-subrc EQ 0.
Loop at itab1 assigning <fs1> from lf_from_index.
If not (<fs1>-matnr = <FS>-matnr and <fs1>-vbeln = <FS>-vbeln and
<Fs1>-posnr = <FS>-posnr ).
Exit.
Endif.
<Delete>
Endloop.
Endif.
Endloop.
5. When using for all entry in, remember to use Delete adjacent duplicates from to delete duplicate records from the table, and use if not interanl table is initial to determine whether the primary table is empty, it is executed only when the primary table is not empty.
The following is a record for today. It is written based on memory and will be supplemented later.