How to collect and analyze traces using ST12 (single transaction analysis)

Symptom

You wish to analyze the performance of a particular transaction/report/job and would like to use transaction ST12 (also known as Single Transaction Analysis).

Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

Transaction ST12 is available as of basis release 4.6B. It is delivered via the addon ST-A/PI (Application servicetools for EarlyWatch/GoingLive, see SAP Note 69455).

The ST-A/PI version should be 01F* or higher.

The feature to switch on the ABAP trace for another user requires:

  • on basis 4.6*: Addon ST-A/PI >= 01F*, Kernel 46D patchlevel >= 1805
  • on basis 6.x: Addon ST-A/PI >= 01G*, Kernel 640 patchlevel >= 83
  • on basis 7.0 or higher: Addon ST-A/PI 01G*

Resolution

ST12 is the Single Transaction Analysis tool. ST12 integrates ABAP traces (SE30/SAT) and Performance traces (ST05) into a single tracing tool.

ST12 will also try to retreive and save to the database up to 20 STAT records (STAD) generated by the the traced user.

ST12 - ABAP and Perf traces.PNG
(Performance traces in ST12 are limited to SQL, RFC, and Enqueue activity)

  • ABAP traces were traditionally captured, collected, and analyzed in SE30 and SAT. ABAP traces are written to ATnnnnnn files in the SAP DIR_DATA directory.
  • Performance traces were recorded and analyzed in ST05. Performance traces are written to TRACEnn files in the SAP DIR_LOGGING directory.
  • STAT records are automatically written to STATnn files in the DIR_DATA dorectory and are typically viewed with transactions STAD and STATS.

We refer to the combined capture and collection of ABAP traces, Performance traces, and STAT records as an "ST12 trace".

Tracing methods, configuration, and collection

  1. Trace for - User/Task

  2. Trace for - Workprocess

  3. Trace for - Current mode

Analyzing collected traces

  1. ABAP trace

  2. Performance traces

  3. SQL Summary

  4. Statistical records

About ST12

Tracing methods, configuration, and collection

Trace for - User/Tasks

With this method, activities of a specific user in the current instance/system are captured.

ST12 - trace for -user_tasks.PNG

1. Configure the trace.

Comment : <something that helps colleagues/SAP identify the trace>

** Server : <instance in which the user will be active; default is the local instance>

Username : <name of the user to be traced>

† No. Trace Activations : at least 20

‡ Size&Duration : Large

** If you don't know which instance the user will be active in, select <All Servers>

† One ABAP trace is activated per matching user session/mode up to the "No. trace activations" value.
This means that if the chosen user has many parallel sessions/modes in the system and "No. trace activations" is set too small, then the activity which you wish to trace may not be captured.

‡ If the activity to be traced is quite long (10+ minutes), it's recommended to change Size&Duration to Max

2. Click the "Start trace" button.

(If you are tracing yourself, or have chosen a Server other than < Local>, there will be a popup. Click the Enter button on the popups to close them.)

You should now see rows in the trace monitor table, and the "Start trace" button should now be "End traces & collect":

ST12 - trace monitor table.PNG

3. Reproduce the problem.

Have the user re-create the performance problem.

It's best for the user to be prepared ahead of time. After the traces have been started, the user should only have to click once to reproduce the problem.

Traces that contain many dialog steps are difficult to analyze. An ST12 trace should contain as few dialog steps as possible.

If multiple steps in a transaction are slow, capture multiple ST12 traces, one for each slow step.

Wait until the slow activity is complete.

4. Once the slow activity is complete, click the "End traces & collect" button.

The "Collect traces" dialogue window will open showing us the ABAP traces that have been captured.

5. Select all the rows in the table and click the Enter button. (Each row represents an ABAP trace)

ST12 - collect traces dialogue.PNG
(If you are trying to trace Update2 tasks, click the Update2 checkbox before clicking the Enter button.)

After clicking Enter, you will see a message:
ST12 - async trace collection started.PNG

6. Wait for the async trace collectors to finish.

7. The traces are now ready for Analysis.

Trace for - Workprocess

With this method, activities of a particular Workprocess are captured.

ST12 - trace for - workprocess.PNG

1. Provide a comment that helps identify the trace to colleagues and SAP.

2. Choose the server that contains the Workprocess that you wish to trace. It's also recommended to set Size&Duration to Max.

3. Click the "Start traces for workprocess" button. You will be shown a screen with a WP table for the chosen server.

4. Select the desired WP and click the "Start traces for selected workprocess" button.

ST12 - WP table - start.PNG

Clicking refresh shortly after starting the trace, each trace should display a green square, indicating each trace is on for that WP.

ST12 - WP table - refresh.PNG

5. When the activity has finished, or after the trace has been on for some time, select the WP again and click the "End all traces and collect" button.

ST12 - WP table - end.PNG

After clicking "End all traces and collect", you will see a message:
ST12 - async trace collection started.PNG

6. Click "back" and wait for the async trace collectors to finish.

7. The traces are now ready for Analysis.

Trace for - Current mode

With this method, activities in the current session/mode will be traced. (In other words, the current SAPGUI window.)

(This means that external activities such as RFC/HTTP calls, even when made to the local instance/system, will not be traced because the FMs & handlers are executed in different sessions/modes.)

ST12 - trace for - current mode.PNG

1. Provide a comment that helps identify the trace to colleagues and SAP.

2. Select either Transaction or Program and provide the name of the transaction/program that contains the steps you wish to trace.

3. Choose whether or not to enable "Particular units".

When "Particular units" is disabled/unchecked, all dialog steps within the transaction/program are traced.

When "Particular units" is enabled/checked, the ABAP trace will not start recording until "/ron" is entered in the command field. Conversely, "/roff" will suspend ABAP trace recording.

(ABAP trace recording can also be turned on/off via the menu: System → Utilities → Runtime Analysis → Switch On/Off)

It's strongly recommended to enable "Particular units" and use "/ron" and "/roff" to trace only the relevant dialog steps. Tracing unecessary dialog steps makes analysis of ABAP traces more difficult.

4. Click the "Execute / start trace" button. You will be taken to the initial screen of the transaction/program that was provided.

5. Recreate the performance problem. (If "particular units" was enabled, use "/ron" and "/roff" to trace only the desired dialog steps.)

6. Click Back (F3) until you reach the ST12 screen again.

When you reach the ST12 screen again, you will see a message:
ST12 - async trace collection started.PNG

7. Wait for the async trace collectors to finish.

8. The traces are now ready for Analysis.

Analyzing collected traces

Once the trace is collected the trace is ready for analysis. In the bottom pane as highlighted, select the Trace which is of concern to us.

 Trace analysis.png

Then select either one of the above 4 highlighted options for the analysis. The 'Full screen' button can be used to show the
overview of all the traces collected.

ABAP Trace

The ABAP trace is one of the most useful analysis options available in ST12 trace. It provides a Top Down flow of any Hotspot/Program/Transaction
and provides a Functional Time Distribution of a flow. It displays the hierarchical order in which the call statements are executed. So it can be used
to identify the issues in the flow hierarchy.
For Basics of ABAP trace, please see SAP Note 755977.

ABAP Trace_1.png

The above screenshot is a Per Call View of the ST12 trace. The view can be changed into a Modularized by selecting the Per Mod Unit button
as highlighted above. This will give a modularized flow of the Code called inside a particular module.

ABAPTrace_2.png

The “Top Down Call Tree”(as highlighted below) option clicked when the cursor placed on a Modularization Unit Call(Method/Performs) displays all calls to the selected unit labeled as ‘0’,’1′ are statements inside this modularization unit, ‘2’ the statements in modularization units one level below, and then iteratively down up to 30 levels. Letters are used to designate lower levels.

ABAP Trace_3.png

Double-clicking on any of the line navigates us to the source code. This can be used to identify the impact point.

ST12 trace captures the minute details of the flow such as the Loop statements performance, which can be used for a detailed analysis of the flow.

As the ABAP trace captures the complete flow, this can be used as an effective tool to identify the Customer Modifications or User Exit.

Note: The call hierarchy considers the call on Forms, Methods, Functions, SQL statements, Loops, Call Screen to PBO, PAI Modules.

Performance Trace

Performance trace of ST12 is equivalent to the ST05 trace. It displays performance parameters of all the database statements executed in the flow.

PerformanceTrace_1.png

SQL Summary

SQL summary is the aggregation of SQL trace records from the Performance trace. SQL 

provides the details like Execution time, No. of records selected, Total duration, server details, etc. on a query on a database table. Double-clicking on any record takes the flow to a screen which displays the list of programs which has queried on the table and the SELECT query as such.

SQL Summary_1.png

Statistical Records

Displays the statistic records saved by the async trace collector for that ST12 trace. These records are the same as the records that can be queried in transaction STAD. Only up to 20 statistic records will be saved.

 Statistics Records_1.png

About ST12

Trace collectors

When an ST12 trace is ended, trace collectors are started asynchronously.

ST12 - async trace collection started.PNG

The trace collectors have 3 tasks:

• Retrieve the ABAP traces from the ATnnnnnn files in DIR_DATA, prepare the ABAP traces for analysis, and commit them to the DB.
• Retrieve the SQL Performance trace records from the TRACEnn files in DIR_LOGGING and aggregate them to generate the SQL summary.
• Retrieve 20 STAT records generated by the traced user and commit them to the DB.

While the async trace collectors are running, the ST12 trace status will be busy : ST12 - status collecting.PNG

When the trace collectors are finished (and after refreshing ST12), the ST12 trace status will be green : ST12 - status good.PNG

Trace collection may require a few seconds or it may take some minutes, it depends on the size of the generated traces.

If the trace collectors fail to finish, then some features of an ST12 trace may be partly or completely unavailable.

See Also

755977  - ST12 "ABAP Trace for SAP EarlyWatch/GoingLive" 
2424940 - How to get ST12 trace for Planning Sequence
1959493 - How to get ST12 trace for DTP request
2169881 - How to trace background job using ST12

Keywords

ST12 trace , performance analysis tool , single transaction , high response time , st12 abap trace , net time , performance traces , SQL summary, stat records , ENQUEUE trace , RFC trace , ST05,SE30, /SSA/STA

原文地址:https://www.cnblogs.com/weikui/p/13450055.html