Professional Documents
Culture Documents
Debugging
Debugging
ABAP Training Debugging Techniques 2
Objectives
Online debugging tools
Starting the debugger
The debugger’s views
Using break points
Setting static break points
Setting dynamic break points
Setting watch points
Setting breakpoints at keywords or events
ABAP Training Debugging Techniques 3
Objectives
Deleting and deactivating breakpoints
Stepping through program codes
Displaying field contents
Displaying internal tables
Displaying ABAP/4 lists
Replacing field values at runtime
Changing internal tables at runtime
Switching to the ABAP/4 editor
Releasing the database during debugging
ABAP Training Debugging Techniques 4
The ABAP/4 debugger lets you stop a program during runtime and
examine the flow and results of each statement during execution.
Stepping through a program with the debugger helps you to detect and
correct errors in your code.This documentation is designed for
developers new to the workbench’s debugging facilities or for those who
want to learn the tool to use the tool more effectively.
ABAP Training Debugging Techniques 5
Contd…………….
Debugging strategies form within ABAP/4 development work bench. We
can set breakpoints in a program and then start the program within the
debugger. Alternatively, we can run the program in the debugger without
any breakpoints.
A breakpoint is a signal within a line of code that tells the ABAP/4
runtime processor to interrupt the program at the line. Setting break
points is a good strategy if we want to examine a program:
After the system has already processed certain events
Debugger’s Views
A debugger selects different views, by selecting appropriate view name in
debugger’s menu.
Purpose of various buttons
Overview - displays the structure of the program to be
debugged.
Fields - displays the fields content and technical characteristic
Table - displays the content of an internal table.
Call stack - displays an active event chain and the call sequence
up to the current breakpoint.
Structure of the debugging view
Each debugging view has the same structure. The top half of the
screen displays a portion of the programs source code. The lower half
shows information specific to that particular view .At the line ‘source
code of’ appears two push buttons to scroll through the program code.
The line currently ready for processing is indicated by “>”.A small stop
sign appears to the left of each dynamic break point .
ABAP Training Debugging Techniques 9
Using Breakpoints
A breakpoint is a signal within a program’s code , which tells the ABAP/4
processor to interrupt the program at a particular point. The type of
breakpoint depends on the purpose of debugging.
ABAP Training Debugging Techniques 10
Types of Breakpoints
Static
These are user independent , set directly into a program’s code with the
editor. User dependent breakpoints also is possible.
Dynamic
Set within the ABAP/4 debugger or editor. This type is visible when the
program is displayed in the editor.
Watch points
Set within the ABAP/4 debugger .Watch points are field-specific. This is
used to observe changes to a particular field .The debugger interrupts
the program when fields content change.
ABAP Training Debugging Techniques 12
When to Use…..
Contd…..
Report rsdebug1
……………
Check account
If SY-SUBRC NE 0.
Break-point.
ENDIF.
…….
When we start the report , ABAP/4 interrupts the processing at the break
point.
We can number breakpoints like BREAK-POINT1 ,BREAK-POINT2..For easier
identification.
ABAP Training Debugging Techniques 16
Removing Breakpoints
It is necessary to remove the breakpoints after debugging. Use function
Utilities Global search to help in locating break-points in larger
programs. It is necessary to remove breakpoints since it may cause
serious disruptions in productive process.
ABAP Training Debugging Techniques 17
Setting Watchpoints
A watch point is set to interrupt a program when the contents of a
specific field or a string change.
Following are the steps to set a watch point.
On the debugging editor, enter the table-field.
requirement.
Fill the appropriate value in the text field next and press the tick .
debugging--> Watchpoint.
ABAP Training Debugging Techniques 19
or function module.
The system will display a small screen prompting to enter statement
and it deletes .
Deleting Watchpoints
Watch points are special break points set for specific fields. To remove a
watch point , the following steps will do.
Choose Goto --> Control debugging-->Watchpoint. A display of the
Contd….
If the space you leave to display a field is too small , the system
truncates the display and indicates this by a “<” character.
As with the field display , we can customize the display format for
internal tables. The standard entry in the format field is an E (for
edited) . you can change this to an X for hexadecimal or a C for
character display.
Once we have finished examining the internal table , return to the
screen with the field display and program code by selecting the program
button.
Displaying ABAP/4 lists.
If we are debugging an online report that generates a list, we can
display this list in the debugger. As soon as this list is started, the display
list pushbutton appears. Choose display list to switch to the list display.
The system displays all the lines generated so far in their respective
formats.
Note : the current list line is formatted only after completion (NEW-
LINE).
ABAP Training Debugging Techniques 27
We can change the values of all fields , database tables (with offset) and
internal tables referenced in a report . if we alter the values of database
fields , we do not change them in the database itself , but only in the
work area ABAP/4 provides for one run of the report .The system
displays an appropriate message if any format errors occur.
ABAP Training Debugging Techniques 28
Editing a Row
The functions change , insert and append are field-specific in the
debugger and can be carried out only one field at a time by pressing the
respective pushbuttons.
For example ,if we want to edit the following line:
Lh001 FRANKFURT NEWYORK 145400 400 x,
We first need to decide which field to change.
Then the following steps must be done.
1.Place the cursor on the row and field we want to edit.
2.Choose change.
3.Enter a new value for the field.
4.Choose enter.
The system updates the line and displays the new contents in the table.
ABAP Training Debugging Techniques 31
Adding a Row
We can add a new row to an internal table by using either append or the
insert function. Append places the new line at the end of the table.
Insert lets us to position the line anywhere.
To add a new row to the end of the table , the following steps will do.
1.Choose append.
2.Enter a value for the first field in the line.
3.Choose enter. The system adds a line to the table and fills in the first
field.
4.Enter the remaining fields of the line by following the procedure for
editing a row as described above.
To insert a new line anywhere in the internal table ,position the cursor
on the line directly following the line where we want the new row to
appear. Then ,choose insert button and proceed as we want to append
the line.
ABAP Training Debugging Techniques 32
Debugging ...
Test/execute
Program B170D051 ...
Debugging Mode
PROGRAM B170D051. O S V F T P
DATA: DIFF TYPE P,
. View pushbuttons
.
.
COMPUTE DATE_1 = SY-DATUM.
.
.
.
Variables
DATE_1 00000000 R
SY-DATUM 19940223 R
R
X R
ABAP Training Debugging Techniques 35
Setting Breakpoints
1
ABAP/4 Editor Menu Utilities
-> Breakpoints
Keyword BREAK-POINT
2
Debugging mode Line selection (double-click)
Menu: Breakpoint
-> Set/delete
Goto
-> Breakpoints
ABAP Training Debugging Techniques 37
Summary
Static break-point are user independent (YES/NO)
Yes
Dynamic breakpoints are not user-specific(yes/no)
No
Dynamic breakpoints are visible in the program(yes/no)
Yes
Dynamic breakpoints are more flexible than static breakpoints(yes/no)
Yes
Static breakpoints are hard-coded in the program(yes/no)
Yes
Temporary deletion of dynamic breakpoints are not possible(yes/no)
No
ABAP Training Debugging Techniques 38
Summary Contd…..
Watchpoints can be set only from within the debugger (YES/NO).
Yes
How can a temporary deletion of dynamic breakpoints are done?
ACTIVATE/DEACTIVATE in the debugging editor.
What are the different options to step through the program in the
debugger?
Single step
Execute
Continue
Return
While debugging ,it is impossible to correct wrong values in a table’s
field dynamically during runtime (YES/NO)
No
ABAP Training Debugging Techniques 39
Summary Contd……
Addition and deletion of fields in a table is possible in debugger
Yes
From the ABAB debugger , switching to ABAP/4 editor is not allowed.
No