Professional Documents
Culture Documents
1 di 5
http://weblogs.sdn.sap.com/pub/wlg/22536
Blogs
Subscribe
Stephen Pfeiffer
Business Card
Company: SAP AG
Posted on Dec. 14, 2010 10:09 AM in ABAP
Print
Permalink
Share
Now that NetWeaver 7.0 EHP2 is available as a Mini-Basis System, we can tell you about some of its new features.
One of the coolest of these new features for problem analysis is ABAP scripting in the New ABAP Debugger. In this weblog, we explain what this feature
is for, what the script workplace looks like, and how to run a couple of first scripts to whet your appetite. Youll see how to do a complete trace of
executed statements from the script overview, and how to see where particular statements occur in your (executed) code.
Here is the video on ABAP Debugger Scripting Basics.
15/12/2010 8.46
2 di 5
http://weblogs.sdn.sap.com/pub/wlg/22536
As you can see, the source code editor is open so that you can edit a standard script template. You can use any standard ABAP OO statements and
constructs that you wish. Plus you can use the method calls from the Script Wizard; these let you make use of the services of the New ABAP
Debugger. (See the weblog on advanced scripts).
You can load a script from the library or from a collection of your own scripts (use a naming convention, so that you can find them again). You can
easily move scripts between systems by downloading them to file and then uploading them again.
To the left of the editor, you can specify when the ABAP Debugger should run the script for example, after every single execution step in the
debugger. The Trigger options have the following meanings:
Execute directly: If you mark this option, the script runs only if you press the Start Script button. The debugger does not run the script
automatically. This is the right option if you are using a script for a single specific task, like dumping the data from a complex data source to a
trace.
After Debugger Events Debugger Single Step: Once you tell the debugger to run the script (with Start Script), then the debugger automatically
runs the script after every debugger single step (F5 Single Step in manual debugging). After every statement is executed by the debugger, the
script runs again. This is the Trigger setting for a full statement-level trace of execution.
After Debugger Events - Breakpoint Reached, Watchpoint Reached: With these options, the debugger runs the script every time a breakpoint or
watchpoint is reached.
Important: The script runs only when the debugger reaches breakpoints and watchpoints defined here, in the context of the script. If you check
one of these Trigger options, an icon appears that allows you to define breakpoints and/or watchpoints for triggering the script. The script does
not run at breakpoints or watchpoints that you may have set separately, in the source code editor, for example. This arrangement lets you
separate breakpoints or watchpoints that are to trigger the script from those that you set for your own use in the debugger.
At the bottom of the screen (not shown in the screen shot) is the Display Last Trace frame. After your script has stopped running, you can use the
buttons in this frame to display the trace (if any) created by the script.
15/12/2010 8.46
3 di 5
http://weblogs.sdn.sap.com/pub/wlg/22536
5. Tell the New ABAP Debugger to run the script by clicking on the Start Script button.
What happens? The New ABAP Debugger runs the program that you are debugging to the next breakpoint (including a stop required by
Layer-Aware Debugging) or until control returns to the program. Its as if you had pressed the F8 Continue button on the debugger tool bar.
At each single-step that the debugger makes, it runs the RSTPDA_SCRIPT_STATEMENT_TRACE script. The script writes each debuggeestatement that is to be executed to a log.
If the program is long, you will notice the trace activity in the form of extra waiting time. For that reason, you may want to run the trace
script only between two breakpoints or in conjunction with layer-aware debugging. Set breakpoints around the code that especially interests
you. Start the script at the first breakpoint. Stop the script and look at the trace when you reach the second breakpoint.
6. Tell the New ABAP Debugger to stop running the script so that you can take a look at the trace.
If you have arrived at the next breakpoint, then the debugger has control. You can tell the debugger to keep running the script or to stop
running the script directly.
If control has returned to the program that you are debugging, at screen output for example, then you need to return control to the debugger
so that you can stop the script.
The debugger returns to the foreground, and you can click on Exit Script or Continue Script.
7. Display the trace in the debugger session or in an internal session by clicking on Display or Start Analysis in New Session.
15/12/2010 8.46
4 di 5
http://weblogs.sdn.sap.com/pub/wlg/22536
The trace shows every statement that the debugger executed. A double-click on a line lets you jump into the source code to see the
statement in context.
8. Click on F8 Continue to run the debugger further and return control to the debuggee.
Bonus: Your Second Script - Finding Out Where Particular Statements Occur
Perhaps you want to find out where AUTHORITY-CHECK statements are executed, so that you can ask a customer for the required authorizations for
debugging a problem. Or perhaps you want to see where your program is selecting data from the database.
With the statement trace script, these tasks are easy to accomplish.
Proceed by doing the following:
1. Load the RSTPDA_SCRIPT_STATEMENT_TRACE as shown above in steps 1 through 4.
2. Change the Trigger setting from Debugger Single Step to Breakpoint Reached. Click on the Change button, which has appeared next to
Breakpoint Reached.
3. Create a breakpoint for the SELECT statement, or the AUTHORITY-CHECK statement, or any other statement you would like to trace.
4. Run the script and take a look at the result, as shown above as of step 6.
15/12/2010 8.46
5 di 5
http://weblogs.sdn.sap.com/pub/wlg/22536
As you can see, you can quickly modify a standard script to perform special tasks in the debugger.
Stephen Pfeiffer
Main Topics
Oldest First
Wow!
2010-12-14 11:55:12 Alvaro Tejada Business Card [Reply]
Stephen:
This is so great...I was wondering how the Script debugger was supposed to work since the first time I heard about it...this blog is really great and
useful...can't wait to create my own script -;)
Greetings,
Blag.
15/12/2010 8.46