Deep Dive into ABAP Debugging - Basic
What is ABAP Debugger?
The ABAP Debugger is the important tool used to analyze ABAP programs. In the development phase of any program, the Debugger can be used to analyze error situations like runtime errors and unexpected program behaviors. Also, it can also be used to analyze existing programs to understand their logic flow.
Versions of ABAP Debugger
How to start ABAP Debugger?
How to start/switch on Debugging when running applications/transactions?
Just like activating debugger with /h in command field, to activate classic debugger enter /hset debugger=classic and use /hset debugger=standard to activate standard debugger. However, this will have effect only on the current logon session. Standard debugger will be the default for any new SAP logon session.
Note: Post SAP release 7.4, Standard debugging has been the only way for Debugging external requests irrespective of the OK Codes used.
Now, how to end Debugging session?
Types of ABAP Debugger
Session Breakpoint
Persistent Breakpoint
Default tools available in Debugging session: -
Other tools available that can be added in the debugger screen: -
We will see about the tools in detail as we go on.
Debugging in ABAP code
Debugger options explained with the purpose: -
Call stack Debugger tool: -
This tool helps to see the programs (call stack) that are called before reaching the debugger stop.
Breakpoints & Watchpoints
All types of breakpoints do the job of the allowing the developers to mark places/statements in the ABAP code where the debugger should start/stop.
Every type of breakpoints has different scopes & lifetimes.
Session Breakpoint
If the breakpoint should be active only in the current user session, then Session break point would be right choice. This breakpoint will get deleted once the user logs off. This breakpoint can be set in the following ways.
External Breakpoint
External Breakpoints will be active/valid for future user sessions. These breakpoints are valid for 2 hours and whenever a new breakpoint is set, the lifetime of all breakpoints is reset. These breakpoints are useful when we want to debug applications/ web services that are connected to SAP via RFC & HTTP request. Also, these breakpoints can be set specific for certain User or a Terminal ID. Following are the ways to set external breakpoint,
External breakpoints can be set for another user, can be helpful when we are trying to debug RFC call or HTTP request made by another user. To do this, follow the below steps,
In cases where the external breakpoint (for another user) needs to be only in the current application server, Flag the checkbox Current application server only.
Debugger Breakpoint
As the name indicates, these breakpoints can be set only in Debugger session, so they are visible in debugger session and deleted right after the debugger session ends. Both Session & External breakpoints can be set on the ABAP statements (Known positions) that is seen on the screen while Debugger breakpoints can be set on unknown positions as well. We will see how to do this.
Set Debugger breakpoints at a known position,
Set the cursor the on the ABAP statement that is of interest, choose Breakpoints -> Line Breakpoint. We get options to Set/Delete & Activate/Deactivate debugger breakpoint.
Let’s see how to set Debugger breakpoints at an unknown position.
This dialog box opens when we press F9 or Create breakpoint. With this, Debugger breakpoints can be created for the following items.
We should enter the class & method to set a breakpoint for the method. Similarly, if we want to set a breakpoint for a method of a local class within any specific program.
Breakpoint Overview
All the Breakpoints that are defined can be seen in within Breakpoint Tab in Break/Watchpoints tab in Debugger session. From this tab, Breakpoints can be created, activated, deactivated & deleted. Also, we can change the type of breakpoint from here.
We can also set conditions for the breakpoints., if we want the breakpoint (that is already set) to be triggered only on for a specific condition. Like the below example, if we want the breakpoint to be triggered only when the username is ‘PRABHAKARAN’
We can also see the overview of Breakpoint from ABAP Editor.
Watchpoints
Watchpoints are a way to make the debugger stop when the value of the variable/data object (for which watchpoint is created) changes.
How to create Watchpoints – Watchpoints can be created only in debugger sessions.
On creating the Watchpoint, we get the below dialog box where we should enter the variable/data object for which Watchpoint needs to be created.
Below example, Watchpoint is created for variable SY-UNAME with condition SY_UNAME = ‘PRABHAKARAN’. So whenever the value of SY_UNAME changes to PRABHAKARAN debugger will stop. If we want the debugger to stop whenever the value of the variable changes, then leave the Free condition blank.
Watchpoints created can be seen in Watchpoints tab under Break./Watchpoint tab in debugger session. We can also activate, deactivate, create, change, delete any watchpoint from here also.
How to save & load Debugger session?
Following the below steps, Debugger sessions can be saved, loaded for a later debugging session, can also be deleted if no longer needed along with components that can be chosen.
Dialog box while saving & loading the Debugger session.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
8 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 |