Blog Corner

How to improve SAP performance with an automated tool
Just with a click ?


Accelerate SAP system

Slow SAP performance causes an uncomfortable working environment for every employee, but actually it’s possible and easy to accelerate SAP with an automated tool.

Performance is related to many things like CPU speed, database speed, memory size , data size, ABAP code performance even connection speed in network.

Yet, it’s still possible to accelerate an ABAP program in a sensible level like %30 – % 40 by just optimizing the ABAP code. Also by using the same optimization techniques you can leverage better from great performance features of HANA database, that’s called optimizing & adapting ABAP for HANA.

Let's have a look automated ABAP optimizations in this online optimizer tool.


Why do performance problems occur ?


After completing your SAP implementation project and going live, in the first years of your SAP system usually you don’t see performance problems because database size is small.

For the same reason developers also can’t notice performance problems in the beginning, they concentrate more on coding the business logic to start SAP life for your company.

But by the time, database grows and non-optimized ABAP codes starts to cause performance problems

SAP ABAP performance versus database size over years

What are automated ABAP optimization techniques in ABAP optimizer tool ?


Let’s examine them in a sequence of importance .. Some optimizations can change ABAP performance in a very visible level so let’s start with them and see how they are automated.


Automated ABAP Optimization 1 :
Reduces Repetitive Database Access ( Collects up SELECT in LOOP states )


Coding database accesses (SELECTs, UPDATEs ) under loops in ABAP , causes too many and repetitive accesses to database server which is resulting poor performance.

Imagine an ABAP code as below :

ABAP SELECT in LOOP causes repetitive database access and slow performance

Database table AFPO will be read repetitively for every single record in internal table IT_CAUFV. It means in every step of the loop , a request will be sent to the database server from the application server just to read a record.

Even on such a strong in-memory database like HANA , this code results poor performance because time will be lost on communication between application server and database server.

By reading data from the database only once and using another internal table as a data buffer , delivers visible performance improvement.

Below are the simple steps .. basically using ABAP’s “FOR ALL ENTRIES” statement :

SAP ABAP improve performance by optimizing SELECT in LOOP with converting to FOR ALL ENTRIES

This is an automatic correction type used in ABAP Optimizer tool ..
it makes this optimization automatically on uploaded ABAP in ZIP file for you :

1-Optimizer declares a new buffer internal table in top include

2-Inserts the SELECT statement with FOR ALL ENTRIES before LOOP statement to fill buffer

3-Then finally converts SELECTs to READ TABLE statements with BINARY SEARCH option.

These all are automated operations made in seconds.

Maybe it would deliver better performance if all data is produced on database with JOINs and aggregation functions or with a CDS view, but that would also require a bigger change in code. Method above is a simple one , it doesn’t even require to think about logic of code.

Automated ABAP Optimization 2 :
Converts READ TABLE commands to use BINARY SEARCH option


If the data in ABAP internal tables are sorted , it’s easier for processor to search and find a record. It's like using a database index for the data in ABAP internal tables.

Let’s have a look at the example ABAP code below :

SAP ABAP improve performance by using BINARY SEARCH in nested loops

Code is simply reading scheduled line data in internal table GT_VBEP for every sales item in SD, there are around 10.000 sales documents in header internal table GT_VBAK and around 100.000 sales items in internal table GT_VBAP.

So how many times the table GT_VBEP will be read ?
if there are nearly 10 items for every sales document
then it will be around 10.000 x 10 = 100.000

It’s a usual coding state which causes to freeze or slow down SAP reports / RFC functions time to time.

What improvement we can make for the performance of READ TABLE command will be 100.000 times effective here.

By changing the code as below, you can see that execution time can reduce to 2 minutes from 20 minutes. Sort table in a convenient position before READ commands and change READ TABLE commands to use BINARY SEARCH option.

SAP ABAP improve performance by using BINARY SEARCH in nested loops - optimized

This is also an automated correction type which ABAP Optimizer makes on code in seconds :

1- For all the READ TABLE accesses in whole ABAP code, it detects common access keys
2-Inserts SORT command in a convenient position before data reading starts
3-Then adds BINARY SEARCH option to all READ TABLE commands automatically

If internal table GT_VBEP is always read with same keys in whole code then using an ABAP Sorted Table is also a method.


Automated ABAP Optimization 3 :
Reduces fields used in SELECTs ( Correct SELECT * ) while reading database


For example, EKPO is a database table belong to logistics and it has more than 250 fields.

In an ABAP function , if only 5 fields are required in code logic and “SELECT *” was used to read the database table than it means data in other 245 fields was redundant,but being transferred from database server. And if you imagine this state in many of ABAP codes in system , off course it wastes system resources and causes a redundant workload.

Reducing fields to only required ones in SELECT statements also in declared ABAP internal tables helps performance. But this requires to have a look whole ABAP code logic to find required fields for all internal tables, including “MOVE-CORRESPONDING” statements and tables in external function / class calls.

SAP ABAP improve performance avoid SELECT * STAR

This is also an automated correction type which ABAP Optimizer makes on code in seconds for you.


Automated ABAP Optimization 4 :
Check Range Tables for FOR ALL ENTRIES statement


Sometimes a very simple missing IF control causes ABAP code to slow down even freeze.

Below is a simple SELECT statement which reads logistics table LIKP from database with ABAP – FOR ALL ENTRIES option :

SAP ABAP improve performance FOR ALL ENTRIES

But if internal table IT_VBFA2 is empty in above example for a specific case, than ABAP interprets this as no limit & range for reading database, so it reads all the data in this database table.

According to the transaction count of a company there can be even millions of records in tables, so table size can be very large in gigabytes. When ABAP starts to transfer all the data from database it just freezes SAP program for a while.

Putting an IF or CHECK statement to control this state before SELECT improves performance.

SAP ABAP improve performance FOR ALL ENTRIES - Optimized

This is also an automated correction type which ABAP Optimizer makes on code in seconds for you.

Scanning ABAP & Detecting Performance Bottlenecks


ABAP Optimizer also has a feature to scan all custom ABAP developments in an SAP System to detect all performance bottlenecks which can be optimized via this automated tool.

Scan your SAP system once to detect all performance bottlenecks and optimize & fix code automatically to reduce system workload. Accelerate SAP system easily without coding anything manually.

Preparing for HANA migration ?
Scan all ABAP developments and use this tool to leverage best from great performance features of HANA database.


Author : Bulent BALCI