Debugging ABAP Program
Debugging ABAP Program
Overview
The debugger is a programming tool that you can use to execute ABAP programs, by line or by section. With
this tool, you can display data objects and check the flow logic of programs.
Debugging Types
Two types of debugging are currently possible:
- debugging with CLASIC debugger for release levels up to and including 6.40
- debugging with NEW debugger which is available for all release after 6.40.
The main differences between the classic and the new ABAP debuggers are described below:
OBS: You can save the current debugger settings and breakpoints in a debugger variant. And after that you
can load the saved variant after starting a debugging session and all settings and breakpoints will be active
at once.
You can specify which parts (layout, breakpoint, settings and options) to store in variant.
You can save the variant as a local file, which you can then email to a colleague, or in a location on the
database, in which case your collegue simply uses the Load debugger variant dialog to load your variant
from the database.
Start New Debugger - >menu path Debugger-> Debugger Session -> Load
Note: in the Classic ABAP Debugger, starting with SAP Web Application Server 6.20, this functionality is
available using menu path Debugging->Sessions
OBS.
1. Not all ABAP code can be debugged:
For example it’s not possible to debug conversion exits and field exits with the Classic Abap Debugger.
During conversion exits, all dialog operations are forbidden (call dialog and call screen); therefore
making it also impossible to send a debugger screen. And another thing: every functionally that is
running for the debugger can potentially affect the debugger’s context. To avoid this risk, the Classic
Debugger does not use Abap for own functionally.
So/..you can use the New Debugger.
2. As a release 6.40, you can select the debugging type as you wish by choosing the classic or the
new debugger in the ABAP Editor : Utilities->Settings.(in user-specific settings)
3. or You can switch the type of debugger at any time during a session (under the menu option
Debugging)
4. As of Release 7.00, the New Debugger is the default.
Setting breakpoints
Dynamic: If the program that you want to debug is not editable / can only be presented in
display mode / has a blue back-ground, one may use this “STOP” / break-point button.
For example: We are going to set up break-points upon execution of a selection, and on the turn of calling a
SAP standard function module.
Position your cursor on the line where you’d like to set a break-point at and click the break-point button
(shown above). For this example, the cursor was positioned at the line “START-OF-SELECTION” and the
break-point button was pressed. The same was done for the line containing the words “CALL FUNCTION
‘TRCA_COMPANYCODE_GETDETAIL’ “. Break-points are now represented as highlighted points in the
program as shown in this picture.
Deleting breakpoints
For “typed” break-point commands, simply erase by backspace or delete the “break-point.” command. For
highlighted break-points, just position the cursor on that line and press the break-point button again from the
toolbar, or one may even go to the utilities part in the menu bar.
1. Using breakpoints
Commonly used keys in debugging mode:
F5 – single step; commonly used for watching values or thorough step by step process
F6 – almost the same with single step but skips sub-routines
F7 – for forwarding to the next break-point or finishing a loop
F8 – run execution
Using my own example, these are the sample input parameters to be used for the rest of the lecture:
Now, upon execution of the selection screen, SAP will forward to the debugging screen
Okay, at this point, s_bukrs-low s_rfha-low and the rest of the field names on the lefts side have no
value yet. Once the abap debugger arrow proceeds to the next line, s_bukrs-low will have the value
of p_bukrs ( in this example is Company Code 1058 ).
After pressing F5, s_bukrs-low acquires the value of p_bukrs, and the debugger cursor moves to the next
line.
From this point, pressing F7 will forward you to the next break-point.
Now, since we’re about to process a SAP standard function module, we have a choice to skip this
part and proceed to the rest of the program (by pressing F6), or continue viewing the process of
this function module (by pressing F5).
Note: if by anytime you want to skip the debugging mode, just press F8.
Pressing F5 you’ll have a view of a SAP standard function module processing, notice the main program and
source code.
From this point, if one wishes to proceed debugging the SAP standard function module, press F5; If one
wishes to pick-up from where we left debugging the main program, simply press F7 and you’ll go to the next
line of the program after the “Call Function ..” statement.
Note: What can we see in Abap Debugger:
- Fields: display fields
- Table: display/edit entries of internal table
Here are the contents of the internal table t_ftr. One may manipulate the current view of the data by
choosing the fields he/she wishes to see, but this doesn’t change the actual structure of the internal
table.
The encircled portion on the bottom right expands the table upwards (if one’s having difficulty
looking at an internal table with many line items).
If one wishes to see the other fields in the table, simply press Shift+F7 to scroll to the right or
Shift+F6 to scroll to the fields on the left. Press Shift+F5 to go back to the original view.
If one wishes to skip the debugging mode, and continue processing the program, go to:
If one doesn’t want to continue processing the program, go to: Debugging>Exit (Shift+F3).
- Watchpoints
- Call stack – display current sequence of events
- Overview – display the structure of the program
- Settings – display the current debug settings
2.
Examples
-
- 3. Now after execute the program as usual (F8), you will be entering the debugging mode. Now
choose Breakpoints > Breakpoint at > Breakpoint at function module
-
-
-
-
-
- 4. Enter the name of the function module you want to debug, click enter to set the breakpoints.
-
-
-
Just use the Process Overview (transaction SM50), select the running
process, and choose from the transaction menu Program->Debugging.
Just choose your job in the Job Overview (transaction SM37) and type “jdbg” into
the command field. The debugger will start, and you just would need to press a
couple of times Return (F7) to get out of the spool functions checks and you can
debug your finished or crashed background job online in dialog.
How to compare ABAP variables – Use the Diff Tool
With the Diff Tool (Diff Desktop) you can compare two compatible ABAP variables,
e.g. two tables, objects, structures or strings. The Diff tool provides differences
concerning type and value. If you double click on a hit in the diff result list, the
variables are displayed in parallel, and the debugger navigates to the difference.
Debugger Variants
/h activate debugging
/ha skip dynpro (PAI, PBO) and directly debug ABAP code