Whenever a SAP coder writes a program. At the time of execution, if it gives a dump or runtime error then SAP debugger is a tool to check your lines of codes and examine error during runtime. Debugging in SAP ABAP helps a programmer to check his program flow at runtime.
We use ABAP debugger by default after the release of SAP 7.0.
In short, we can define as:
- A tool to analyze ABAP programs.
- A tool to examine errors in codes during runtime.
- A tool to display data objects.
- A tool to understand the flow logic of codes in a program while executing.
Stepping through a program with the debugger helps you to detect and correct errors in the source code of an ABAP program.
What is a Breakpoint?
A signal which tells the runtime processor to interrupt processing and start debugging.
It gets activated when the program reaches that point.
How can we debug
By setting a breakpoint
Start the debugger by setting and managing the breakpoints and executing the code.
By running the program debugging mode
We can enter the debugging mode by using \h from any screen.
This can be done when we want to check the program from the beginning and are not familiar with the program.
Types of Breakpoints
There are two types of breakpoints:
A. Static Breakpoint
- This breakpoint is not specific to a user.
- To use a static breakpoint use ABAP Keyword BREAK-POINT.
- Place it in the line where you want to use the breakpoint.
…..if sy-subrc<>0 .
- If you want to set a static break-point specific to a user.
Kindly delete the static breakpoints manually in development system itself, else it might affect the program in the production system.
B. DYNAMIC BREAKPOINT
- These are breakpoints that are triggered when the program that you are running reaches a particular ABAP statement or exception class.
- When debugging session is finished it gets deleted automatically.
- U can set a dynamic breakpoint, either in an ABAP editor or directly in the debugger.
c.1. For setting dynamic breakpoints in ABAP editor.
c.1.1 Position the cursor on the line of source code where you want to set the break-point.
c.1.2. Go to utilities->breakpoint->Set/Stop. The system confirms that breakpoint is set.
c.2. For setting a dynamic break point in debugging mode:
c.2.1- Position the cursor on the line where you want to set the breakpoint.
c.2.2- Select the line by double -clicking it or by choosing Breakpoint-> set/delete.
NOTE: A user can set 30 dynamic breakpoints without changing the program code.
- Session breakpoint
Specific to a particular ABAP user session. If the user session is ended (log off sap system) all session breakpoints get deleted.
- External breakpoint
They are applied to the current user session as well as future user sessions.
e.1. Works in sessions initiated with RFC or HTTP requests or any other external interface.
e.2. An external breakpoint can apply to:
e.2.1.A user in the current SAP system
e.2.2. A user in the current application server of the current SAP system
e.2.3. User sessions started by a request that has a specific terminal ID.
NOTE: Session, External breakpoints can be created at runtime and can be activated/deactivated.
Special KEYS in Debugging
F5- Executes a program line by line.
F6- Executes a function module or a subroutine without entering into it.
F7- Executes a module or a program in a single step.
F8 – Executes a program directly. If there is more than one break-point, then can move to one break-point to the other.