SAP System Setup Training Course
Reveals How To Setup A Free SAP Developer System.
Learn SAP & Practice For Certification. Developer Tips Included:

ABAP Programming With The ABAP Workbench – The Tools You Must Learn And Master

ABAP Programming is a skill that involves learning how to master the ABAP Workbench toolset. Here you will get an introduction to some of the most important tools which an ABAP professional needs to master. Although in-depth knowledge of ABAP is not required, you should have some experience with ABAP.

Undoubtedly, the most important tool in a ABAP programmers toolbox is the ABAP debugger, but here in this tutorial we are not going to focus on that, rather we will focus on “Tools for Analysis”. In a later article I will focus on “Tools for Troubleshooting”.

Tools for Analysis

ABAP Code Inspector (TCODE – SCI)

With the help of the code inspector you can check your ABAP code for performance, security, syntax, error proneness and Statistical information. You can perform different code checks using this tool on a single object (simple check on programs, function modules or classes) or a set of objects (special check on set of objects).

Example of Checking a single object:

Calling code inspector for single objects is very easy, to call it from programs go to Program (SE38) then from the menu choose Check=> Code Inspector

ABAP Code Inspector

From Function Modules go to Function Modules – SE37 then from the menu choose Check=> Code Inspector.

ABAP Function Modules Code Inspector

And from a class go to Class (SE24) then from the menu choose Check=> Code Inspector.

ABAP Class Code Inspector

After calling the code inspector your ABAP code will be checked using the Default Check Variant deliver as standard for the Code Inspector, but you can create your own Check Variant. When the code inspector finishes its inspection you will get the results in hierarchal order.

ABAP Code Inspector Results

This hierarchy contains list of checks on each category i.e. Performance, Security, Syntax, and General. By going down the hierarchy we can see the ‘Messages’ which contain the source code position and a short explanatory text.

1

To get the detailed information for each check that was performed click on the information icon besides the message.

detailed information

And by double clicking on the message text you can go to the inspected line of code.

inspected line of code

Checking object set: We will learn how to use code inspector to check Object Set in the separate tutorial dedicated on that.

We have seen a simple way to analyse our program for Performance, Security, Syntax, Error proneness, and Statistical information using code inspector. It is important to understand some of the limitations of the Code Inspector:

  1. Inability to handle ABAP Joins and Database Views.
  2. Inability to detect LOOPS in called MODULES.

ABAP Runtime Analysis (TCODE – SE30)

With the help of the ABAP Runtime Analysis tool you can check the performance of any ABAP Reports, Function modules or Classes. Using this tool you can interrogate the execution time of your code and evaluate your program on an ABAP code, Database and System level.

To start the ABAP Runtime Analysis go to transaction code SE30 and then select the radio button based on what we want to evaluate. In this example we will learn how to evaluate a program using the ABAP Runtime Analysis tool, but the process is the same for Classes and Function modules. Select the program radio button and enter the name of your Program.

ABAP Runtime Analysis

Now, click on the Execute button. After pressing the Execute button you will see the selection screen of your report and in the status bar you can see the message as ‘Measurement Started’.

clip_image016

Now provide the required values in the Selection Screen of report and hit the F8 button.

After finishing the execution return back to the initial screen of the ABAP Runtime Analysis by pressing the back button.

You will see the following message at the status bar.

When you return back to the Runtime Analysis screen you will find some new parameters added in this screen as shown below.

ABAP Runtime Analysis

Click on the Evaluate button and you will see the overview of the Runtime Analysis Evaluation in a graphical format.

Runtime Analysis Evaluation

As mentioned before the total time is evaluated in three parts ABAP, DATABASE and SYSTEM.

From the total time we can say whether our program is fast or slow but to dig deeper and work out how to optimize performance, take a look at the percentages. This will give us a good starting point as where to begin further interrogation.

ABAP Runtime Analysis EvaluationNow, click on the ‘Hit List’ button to summarize the measurements of execution and processing times into one entry per operation.

The important measured values are ‘No.’ (column 1), ‘Gross’ (column 2), and ‘Net’ (column. 4). They tell us how often an operation was executed (column 1), and how much time it required, either as a total including sub-operations (Gross time – column 2), or without sub-operations (Net time column – 4). Remember that the times are measured in microseconds (ms) and that the shown times are the total times, not the times per execution.


Performance Analysis (TCODE – ST05)

With the help of the Performance Analysis tool we can perform SQL Trace, Enqueue Trace, RFC Trace and Table buffer Trace. Using SQL Trace we can monitor database access, Enqueue Trace help us to record locking activities, RFC Trace provides information about remote calls between instances and Table Buffer trace is nothing but the memory trace. All of this is recorded in a trace file for you to view and analyse.

To start the Performance Analysis tool go to transaction code ST05. Here you can see the Trace screen with all the Trace Options. By default the SQL Trace check box is selected.

Performance Analysis

Now, in a new session open your report program which you want to trace. After preparing your report for execution i.e. providing all the selection screen parameters, return to the Performance Analysis screen and click on the ‘Activate Trace’ push button.

SQL Trace

Now, return to your report and hit the F8 button to execute.

When the report has successfully executed, go again to the Performance Analysis screen and click on the “Deactivate Trace” push button.

Deactivate Trace

Now we can view the Trace results by clicking on the “Display Trace” push button.

Display Trace

Once you press the Display Trace push button, you will see a dialog window where you can set restrictions to display the trace file contents.

Set Restrictions for Displaying Trace

After entering your restrictions click enter to view the Trace List.

Trace ListIn the top row Trace List displays Transaction, Work process Number, Process Type, Client and User. In the Trace List you can see the runtime duration for each of the statements in milliseconds & microseconds, name of the database table accessed, operation which is performed on the database, number of records processed, complete statement and its return Code.

By selecting a row and the clicking on the Explain tab we can see the detail execution plan of that statement.

Trace List 2

In the screenshot below you can see the ‘Estimated Costs = 3’, but for optimum performance this value must be ‘1’. This tools is used very often and I recommend you master it to help improve and optimize your program executions.

Trace Explanation

Summary: In this tutorial we have seen how easy it is to analyse our ABAP code by using these SAP provided tools. These tools will definitely help us in optimizing our ABAP code, enhance their performance thereby reducing the total workload on our system.

In the next article on ABAP Programming With The ABAP Workbench, we will learn to use tools which will help us troubleshooting ABAP code quickly and efficiently.

Categories

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon