Anthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 17 years of experience in SAP R/3 business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at firstname.lastname@example.org.
SAT – Analyze the flow of an ABAP program
Lets pick up from last month… After digesting the first 2 blogs in this series, you now basically have everything you need to start using the SAT transaction. We learned how to efficiently navigate the NEW UI tools and tool-sets. We took a deeper dive into each tool to see how to use it.
So now lets look at some examples of what you might need to do at work. For instance, you may need to find the exact source code location of a particular ABAP statement (a method call, function call…). OK.. lets get started!
I am going to use the DEMO Car rental program delivered with SAP. The transaction code is /nDEMO_CR_CAR_RENTAL. When you execute this, you will be asked if you want to use the CLASSICAL or WEB Dynpro versions. For our purposes, lets use the good old Classical Dynpro (See below)
Click the green check and Viola! Nice… brings me back to the good old days…. Anyway it should look like the one below.
The one above has some data I created before hand just for this Blog, you’ll need to do the same.
Now imagine, that our task is to add some changes to the car reservation record before it gets written into the car reservation table. We need to find out which ABAP program, (or method, function module…) writes the car reservation record into the car reservation table and where exactly in the ABAP source code this occurs.
SAT – How to find exact source code line of an ABAP statement
OK, lets get started. First we need to execute SAT (Duh!). Once the screen is up, we need to (Do What?) Create a Measurement Variant. Good Answer! You remember how to do this right? No? OK, see steps below…
1. Start the ABAP Runtime Analysis (SAT) via System -> Utilities -> Runtime Analysis -> Execute or call the transaction directly with “/nSAT”.
2. Enter the transaction “DEMO_CR_CAR_RENTAL” into Transaction field.
3. Choose Eval. Immediately to start the analysis right after the measurement.
4. Choose Determine Names of Internal Tables. That way we can see the names we give the internal tables in the measurement instead of some obscure ABAP internal reference like “IT00”.
5. Lets type in variant name of “zProgramFlow” and hit the create button to create a variant.
6. On the Duration and Type Tab – Set aggregation to None, and choose Explicit Switching on and Off of Measurement to turn on/off trace only for the needed program parts to reduce a trace file size.
Some further clarification on #6 – Don’t use aggregation if you want to trace ABAP in order to follow the program logic (what we are doing here). Aggregation summarizes the trace data for a particular type of event in a single trace record and therefore reduces the number of entries in the trace file. But to see the complete program flow you need all trace data.
7. On the Statements Tab – Choose all Processing Blocks, and additionally all operations on Internal Tables since we want to trace where a car reservation record is written into the reservation table. Try and Restrict the measurement only to the really required ABAP statements in order to reduce the trace file size.
For most measurements it would be enough to trace only Processing Blocks.
8. Now hit SAVE!
Now we can execute this measurement. Press the execute button and the car rental application starts.
Before we create a car reservation for a selected customer, turn on the trace with “/ron” in the OK code field (or use System -> Utilities -> Runtime Analysis ->Switch On).
Create a car reservation.
Now turn off the trace “/roff“ in the OK code field (or use System -> Utilities -> Runtime Analysis ->Switch Off).
OK, now since we checked the box Eval Immediately, the results open and should look like the screen below
Now we can switch to the Call Hierarchy Tab and we can see the complete program flow between the /ron and /roff commands.
OK, going back to the task at hand, we need to find out where this object creates a car reservation. If we click on the binoculars icon we will be presented with a sub-screen where we can enter values for different tokens in the Hierarchical Display. We should choose Statement/Event and type the command “INSERT” and execute. Remember we are looking to find out where the rental record is inserted into the transparent table.
We will be presented again with a Sub-screen of the “Hits” for the value “INSERT”. We should scroll down till we see something to do with inserting a “Car Reservation” . Then click on a line to set focus and click the Position in Call Hierarchy button (see below).
OK, almost there! Now look right above the line we are on (highlighted above) and there it is. Can you see it? INDEX 1934 in the screen shot above. The line shows us that we create reservations by Calling the static method CREATE_RESERVATION in class CL_DEMO_CR_RESERVATIONS_MNGR.
Double-Click that line and your in the code!
We could stop here, since we found the Method that creates the Car Reservation. But lets dive one more layer deeper. We are in the code, so double-click on the method CREATE RESERVATION. Now we are in the method and there is the INSERT statement for the Transparent Table DEMO_CR_RESERVTN. We have found the exact statement that will externalize data to the DBMS.
That’s it. Add your changes here. Look for an exit, maybe a BAdi, or Explicit enhancement or section. Or if its your code, before the MOVE-CORRESPONDING do what you need to do.
We used the SAT transaction to trace the program flow of the delivered Car Reservation DEMO application. I hope you can see the advantages SAT has over SE30, such as a modern state-of-the art UI, new analysis tools, easy navigation between tools etc…
Take some time to investigate the New SAT Run Time Analysis Transaction further a by viewing the 20 minute video Below. It’s worth your time. You’ll see some of what I have been describing in real time and see how to use SAT for Performance Analysis.
I hope you see the value in this tool and add it to your ABAP skill toolbox.
To read the first part of this blog series, which is an introduction to SAT, click Below.