ST12 – tracing an already running program
Imagine you started a program which runs longer then you expected. The program is still running and you wonder what the program is doing. This time we use ST12 to perform an ABAP and SQL Trace on a program that is currently running.
Before you start:
Please read the “Before you start” section in this blog first:
We’ll use the same tracing options as described in the above mentioned blog. Therefore the explanation of defining the measurement scope is skipped here.
ST12 – The Workprocess trace:
After you have defined the measurement scope (ABAP trace with internal tables and SQL trace) and set the trace options (file size and duration) as described in the blog above click on the Workprocess Button (Nr. 1 in figure 1). The screen will look like the one shown in Figure 1.
Figure 1 – The Workprocess trace
Since both the ABAP and the SQL trace are application server specific you have to choose on which application server you want to start the trace. For doing so click on the “Choose application server” button (Nr. 2 in figure 1) and choose one application server from the appearing popup (Nr. 3 in figure 1) by marking it and confirming with the green tick. If you don’t choose an application server the local application server is used as the default.
Starting the trace
If you click on the “Start traces for workprocess” button (Nr. 4 in figure 1) a screen like the following appears. The list is quite similar to the process overview (SM50) for the server you have chosen.
Figure 2 – The work process list
Mark the process you want to trace by simply clicking on it. Then activate the trace by clicking the “Start traces for selected workprocess” button (Nr. 5 in figure 2) or press SHIFT + F7. You will see yellow triangles or green squares in the columns for each trace. A yellow triangle means that the trace has been activated but nothing has been recorded so far. The green square means that the trace is active and has recorded actions. In figure 2 the ABAP trace has already recorded some actions while the SQL trace is only active but has not recorded anything yet. After some time when you want to finish the trace click the “End all traces and collect” button (Nr. 6 in figure 2) or press SHIFT + F1. You can see the appropriate status messages for both in figure 2. After going back to the main screen in ST12 and when the ABAP trace has been imported into the database the traces are ready for analysis (like shown in the above mentioned blog).
In case you don’t deactivate the trace before the transaction is finished, the ABAP trace ends with the traced transaction whereas the SQL trace continues with workprocess filter. So if another program starts on the same workprocess it will get SQL traced (but not ABAP traced).
Tracing processes on remote application servers
ST12 makes it easy to start application server specific traces remotely on other application servers, as shown above. You simply have to choose the application server from the popup. With SE30 and ST05 you have to be logged on to the server where you want to start your trace e.g. by “jumping” to the desired server in transaction SM51. For SE30 you have to use the “In parallel session option” which is similar to what is shown here. For the SQL trace you would have to use ST05 activating it with a filter using the Workprocess Number from SM50. However ST12 triggers the traces (SE30 and ST05) remotely that means the trace files are written on the remote server. After the trace is finished ST12 imports the SE30 trace file from the remote server into the database. It can then be evaluated on any application server in the system. For the ST05 trace if you click on the Performance trace button in the right corner on the bottom you will be logged in automatically on the server where the trace has been taken on. This of course only works if the trace has not been overwritten in the mean time since the ST05 trace is not imported into the database by ST12.
Background information on trace recording
There is one thing you should keep in mind when working with workprocess traces.
A trace that is activated for a workprocess does not record the action that is currently executed but the NEXT action after the current execution.
Both, the ABAP trace and the SQL trace will be switched on immediately when you activate the trace (Nr. 5 in figure 2). Since ABAP actions usually have a rather short duration compared to SQL statements this can lead to the following behavior.
Figure 3 – Trace recording
Take a look at figure 3. A trace is activated (T2) just after a SQL statement has started. This SQL statement for instance has to search through many database blocks and could run for hours. If the SELECT statement is doing I/O and evaluating thousand of database blocks in order to find those rows that are specified in the WHERE clause but has no hit, no FETCH will be done and nothing will be recorded. If the SELECT statement delivers thousands of records you will see many FETCH lines but not the OPEN cursor statement since the trace has been activated after the cursor was opened. Without the OPEN cursor action you can’t get the source of the SQL statement in the ABAP program. The information in the traces for activation at T2, T3, T4 or T5 can be the same (might only defer in the number of FETCH actions recorded) and will not show you the source of the long running SQL statement. This means the useful trace information is only like the time spanning TC2 in figure 3. Only the activation at T1 will record the whole SQL statement including the OPEN cursor action on the database. The useful trace information is like the time spanning TC1 in figure 3.
Note: If a trace only contains FETCH actions and no ABAP action like it would be the case for an activation that starts at T2, T3, T4 or T5 and ends before the next ABAP statement is executed (Nr. 7 in figure 3) the whole trace will be considered as initial and nothing will be stored in ST12, because only FETCH operations without an OPEN cursor operation are not helpful for performance analysis.
More information on ST12 can be found here: