Consultants or Support Consultants like me know this situation quite well: You are at a customer and you are asked to trace and analyze a background job which runs outside of office hours e.g. from 04:00 am to 04:30 am. This blog will show you how to have a good and non-disrupted sleep at night WHILE the job will be traced automatically by ST12.
Before you start:
ST12 is delivered as a part of the Service tools for Applications (ST-A/PI). SAP note 69455 describes how to get the latest version of the ST-A/PI. Watch out for the support package for the 01N_* version which is RTC (released to customer) since 21st of November.
Please note that the ST12 transaction is not officially documented / supported and only available in English language. Although it is mainly intended for use by SAP or certified Service consultants during SAP Service Sessions, you can use it for your own performance analysis. A brief description of ST12 is given in SAP note 755977 (ST12 “ABAP Trace for SAP EarlyWatch/GoingLive”). A few blogs on ST12 can be found in the ST12 WIKI in SDN:
Schedule a trace:
Since the program we want to analyze runs outside of office hours we would like to schedule a trace that starts automatically when the program starts without manual interaction from us. Let’s see how this could be done in ST12.
Like always in ST12 we first specify the ABAP and performance trace options (see bullet 1 in figure 1) as explained Single Transaction Analysis (ST12) – getting started and ST12 – 01N_* SP1 new features. This has to be done on the main entry screen. Then we can click on “Schedule >“ (see bullet 2 in figure 1, before it was Menu Utilities->Schedule trace->for batch job or work process from the menu).
Figure 1: Define Measurement Settings
In the next screen click on “for Background job” (see bullet 1 in figure 2). In the upper half of the screen (see bullet 2 in figure 2) you can specify selection criteria for the job like you would do in transaction SM37. You can filter for Job name, User name (The name of the SAP user who scheduled a job or job-step. This is not necessarily the user under whose authorizations the job runs), ABAP program name and Step variant name. If more than 1 job is found, a work process trace will be activated for the first matching job returned from the database.
Figure 2: Schedule Trace for a background job
In the lower part of the screen we can define a time frame (see bullet 3 in figure 2) in which a matching job is searched (the default setting is the next 24 hours).
Additional settings can be applied (see bullet 4 in figure 2).
The trace duration specifies how long the trace should remain active after trace activation. This setting overwrites the setting from the ST12 main screen.
The Trace start delay specifies how long the trace activation for a running job matching the filter criteria from the upper half of the screen should be delayed.
The check interval specifies in which intervals the demon wakes up in order to select matching jobs. You can choose between 60 seconds or 10 seconds.
The #Follow-up traces specifies how many traces should start for the same job after the first trace has finished due to trace duration or size limit.
In the comment field you can add a comment in order to identify your trace later.
What happens technically in the background is described here. The demon is an asynchronous RFC that runs in the time frame specified (see bullet 3 in figure 2). That RFC sleeps 10 or 60 seconds (depending on the setting made in check interval, see bullet 4 in figures 2) and selects from the view V_OP with the given filters (see bullet 2 in figure 2). The trace demon stops when the end of the time frame is reached or when a job that fulfils the criteria is found in V_OP. The first job returned will be used in case there are multiple rows. Once an active job that fulfils the criteria is found another check interval seconds is waited (during which the selected job must still fulfil the criteria), then the work process trace is started for the work process that executes this job.
Please note, that all specifics from the work process trace described ST12 – The workprocess trace apply for the scheduled trace as well. The most important topic to understand here is that trace activation is only possible if the ABAP program is active in the ABAP VM, because only then the ABAP and SQL trace can start running. If the program is not active in the ABAP VM but outside of it when the trace activation is requested in the kernel, e.g. during long running SQL statements or RFC calls, the trace will only get to status green when the control is back in the ABAP VM. This means it may happen that you miss a certain part in the trace when trace activation was not possible for a longer time because the program was e.g. busy on the database. For this scenario I’ll write another blog soon. Some tips for this situation you can find in my book (mentioned below) as well.
Monitoring Scheduled Traces:
This section describes how to monitor scheduled traces. Once a trace is scheduled the green light shows that the master trace demon is active. Additional sub demons are started per instance. For each scheduled trace the status can be monitored in the lines in the table (see bullet 1 in figure 3). The possible states are
– Glasses – “Checking for active suitable batch job” (bullet 1 in figure 3)
– Yellow – “ABAP trace switched on for work process” (bullet 2 in figure 3) – This is the state when the trace is active for ABAP and SQL trace but not no trace records are written yet because the control is outside of the ABAP VM.
– Green – “ABAP trace switched on for work process” (bullet 3 in figure 3) – This is the state when ABAP and SQL trace have started recording successfully.
– Log – “Archived / Trace collected” (bullet 4 in figure 3) – This is the state when the trace is finished and collected. The trace request is archived.
Figure 3: Monitoring scheduled traces
For all states the log of the demon can be analysed by double clicking on the icon shown on bullet 5 in figure 3.
The log (see bullet 6 in figure 3) shows the detailed steps executed from the demon that match the states described above.
This blog described how you CAN have your cake and eat it too. That is having a good sleep at night while ST12 does the tracing for you. You can start your trace analysis conveniently after having a coffee in the office the next morning.
Like always ST12 works system wide that is you don’t have to care for application servers like in SE30/SAT/ST05. A scheduled trace on application server A will find and trace a matching job on application server B.
More information on ST12 can be found here: