There are many tricks and tips which can be used for SAP ABAP performance tuning for reducing the time consumed in program execution.
Using ABAP sort in place of order by, order by clause is executed in database server whereas ABAP sort statement is executed in application server, collecting the data in internal table and using sort command to search executes the search much faster than order by. Another tip for SAP ABAP performance tuning is use of aggregated functions in place of loops for finding highest value etc. in a table, using parallel cursor technique in place of nested loops and using selection criteria in place of check clause in select endselect loop.
Selection with index support, selection with into table clause and selection with selection list in place of select endselect loop with check clause are few tips and tricks for SAP ABAP program performance tuning. Copy, modify and delete are the tasks which are required in an application many times, performing these tasks with help of loops is easy but wastes lot of execution time. Normally, a loop is run on the table and corresponding commands are given to perform any of these activities like append, delete or modify in the loop body, in place of this, use of modify command or delete command with necessary parameters can save lot of time. Appending two internal tables by using append lines in place of loops more frequently is a good SAP ABAP performance tuning trick. Avoiding use of select distinct clause and using abap+sort delete adjacent duplicates for deleting duplicate rows is also a good way of tuning the performance of a SAP ABAP program.
Deletion of variables and constants those are declared but are unused in the program save lot of program memory to speed up its execution. Declaration of too many global variables shall be avoided and in place of this local variables or passing variables by means of parameters to internal subroutines shall be practiced for lesser execution time. In select command selecting proper fields in the same sequence by which they reside in the database is another ABAP performance tuning tip which is normally ignored by most of the programmers.
Use of equal to operand for copying internal tables in place of loops, avoiding joining more than two databases with join command, completely avoiding use of sort inside a loop and not using delete or sort on a hashed table are few other tricks and tips for SAP ABAP performance tuning. Deleting the records of an internal table in loop endloop shall not be done, case statement shall be used in place of if or nested if's and conditions shall be put in a way that those conditions are processed first which are true in most of the conditions. Use of binary search, use of between clause while running a search on huge internal table makes search quick and efficient and defining workarea with loop and read table commands are good SAP ABAP performance tuning tricks.