ABAP for newbies: Get your program up to speed

With the new build of the SAP NetWeaver 2004s ABAP trial version (SP11), you may need to update your ABAP developer skills (beginners and experienced) to understand the new version. By the end of this tip series, you should have a good understanding of what's going on in the ABAP application server. In part 13, Johannes Tillinger gets your program up to speed!

Overview & Introduction

Normally you use the runtime analysis tool to measure the runtime of complex program segments or complete transactions (if you want to measure the runtime of smaller program segments or individual ABAP statements you can use the ABAP statement GET RUN TIME FIELD ).
However, we use only simple examples in this weblog, in order to make the understanding easier.

The runtime analysis tool allows you to examine the performance of any ABAP programs, such as reports, subroutines, function modules or classes, that you create in the ABAP workbench. It saves its results in performance data files, which you can display as lists. You can use these results to identify runtime-intensive statements, to combine table accesses, and show the hierarchy of program calls.

The Programs to be Analyzed

  • reading data from a database table
  • storing that data in an internal table
  • display that data on a list (at the start of the program you have to specify certain key values; only matching data should be displayed later on).

So here it comes (and it seems to work as designed ...)

REPORT  y_wlog_atra_1.
PARAMETERS: p_carrid TYPE sbook-carrid DEFAULT 'LH',
p_connid TYPE sbook-connid DEFAULT '0400'.
DATA: wa_sbook TYPE sbook,
itab_sbook TYPE STANDARD TABLE OF sbook.

SELECT * FROM sbook INTO wa_sbook.
CHECK: wa_sbook-carrid = 'LH' AND
wa_sbook-connid = '0400'.
APPEND wa_sbook TO itab_sbook.

LOOP AT itab_sbook INTO wa_sbook.

A nice colleague has thrown a glance at my source code. He has given the hint to use a WHERE clause with the SELECT statement instead of the CHECK statement for reasons of better performance.

So I have written another program:

REPORT y_wlog_atra_2.
SELECT * FROM sbook INTO wa_sbook
WHERE carrid = 'LH' AND
connid = '0400'.

APPEND wa_sbook TO itab_sbook.

Let's assume I am a very newbie in ABAP and I have written a tiny little program which is doing the following: I am curious about the performance now. Let's compare the 2 variants with the ABAP Runtime Analysis tool.

ABAP Runtime Analysis: Tool & Procedure

Test --> Runtime Analysis SE30

The runtime analysis procedure consists of two parts:

  • Recording performance data (upper part of the screen)
  • Analyzing the performance data (lower part of the screen; this part only appears if there are performance data files in place)

The procedure for the first part (Recording performance data):

  • We go to the initial screen of the runtime analysis (transaction code SE30 ) and specify the name of the first program (Y_WLOG_ATRA_1) in the relevant input field. After that we press the button Execute .

The selection screen of the program Y_WLOG_ATRA_1 (including the 2 input fields) is displayed. At the bottom of the screen we are informed that the measurement has been started. We continue by clicking the Execute button.
Later on we will see that a file (containing performance data) has been created in parallel.

Now we repeat that procedure for our second program (Y_WLOG_ATRA_2).

The second step is the analysis of the generated performance data.

To do that we have to go to the initial screen of the Runtime Analysis tool again. On the bottom part of the screen you can specify those performance data files you want to analyze.

You can see some information related to the last measurement run (in our case that was program (Y_WLOG_ATRA_2). By pressing the button Other File we are able to select those performance data files we like to analyze.

I want to see all the files I have created (user BCUSER).

I get the relevant list with 2 lines (related to the performance data files of the programs Y_WLOG_ATRA_1 and Y_WLOG_ATRA_2).

Based on that list you can display the distinct performance data per line. You have to click in the column Object Type of the relevant line.

As a start the tool displays the evaluation overview (showing the cumulated execution times for the ABAP, database and system-level).
Here comes the evaluation overview for program Y_WLOG_ATRA_1

We can do the same for the other program Y_WLOG_ATRA_2

By comparing the perfomance data of the 2 programs we clearly see that I have done well with listening to the advice of my colleague. The performance of the second program is dramatically better.

In the next step you can forward to a more detailed display of the performance data (Hitlists). That listing shows the different granular execution steps ( according to your filter adjustments ). Here you can easily identify the most time-consuming progam units.

And it will also be a good idea to glance at the Tips & Tricks corner. You will find many valuable suggestions about good performance definitely.

Johannes Tillinger is working in product management ( SAP NetWeaver ).

This content is reposted from the SAP Developer Network.
Copyright 2007, SAP Developer Network

SAP Developer Network (SDN) is an active online community where ABAP, Java, .NET, and other cutting-edge technologies converge to form a resource and collaboration channel for SAP developers, consultants, integrators, and business analysts. SDN hosts a technical library, expert blogs, exclusive downloads and code samples, an extensive eLearning catalog, and active, moderated discussion forums. SDN membership is free.

Want to read more from this author? Click here to read Johannes Tillinger's Weblog. Click here to read more about ABAP on the SDN.

To start it, choose in the SAP Menu, or use transaction .

Dig Deeper on SAP ABAP