16 Debugging Techniques
16 Debugging Techniques
16 Debugging Techniques
Debugging
Branching to Debugging Mode
ABAP/4
Debugger
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
Debugging
The Most Important Debugging Functions
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
Debugging
Database Release
Activate/Deactivate Breakpoints
Debugging
A detailed explanation of ABAP/4 Debugging.
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.
Debugging
After working through this slides , you should be able to debugg both
familiar and unfamiliar programs effectively. With this slides, you will
learn how to
debugged.
•S Call stack – Displays an active event chain and the call
sequence up to the current breakpoint.
•V Variables – Displays the contents up to four fields or field
strings.
•F Field display – Displays the fields content and technical
characteristics.
•T Table Display – Displays the content of an internal table.
•P Programs –Displays all programs needed to run the report
or transaction to be debugged, including
system program
Debugging
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 .Next to the Line Display
appears two push buttons + sign and – sign , 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 .A red light appears
at the bottom of screen after reaching a break point.
If no breakpoints are present, the light is green.
Using 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 invisible 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. Only one watch point is
possible at a time.
Debugging
Key word or event breakpoints
Set within the ABAP/4 debugger. The debugger interrupts the program
when the ABAP/4 processor comes in contact with a specific key word or
event in program’s code.
We can set watchpoints only from within the debugger.They are useful if
we want to interrupt a program only when there is a change in a particular
field or a field string. We can set and remove watch points as
Needed .This , as dynamic breakpoint , does not disturb the other users
of the same program.
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.
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.
Debugging
Setting Dynamic Breakpoints
UtilitiesBreakpointsDisplay function.
Debugging
Setting Watchpoints.
display view.
•The field view displays the field’s content and offers detailed
information about its technical nature.
•Set the watch point checkbox to the right of fields name.
•Continue executing the program by choosing Continue.
Debugging
Displaying the current watchpoint.
During the debugging process, the breakpoints in the earlier run need to
be ignored.In case of static dynamic breakpoints it is flexible during
runtime. In case of dynamic breakpoints, there are more possibilities of
controlling it ,than static breakpoints.
Dynamic breakpoint are not written directly in the program’s code. It can
be deleted or temporarily deactivated and reactivate breakpoints at
keywords or events as the same way as dynamic breakpoints.
Debugging
Stepping through program code.
From within the debugger several options for stepping through the
program.
From within the editor, deleting the dynamic breakpoint is done by the
following steps.
•Choose UtilitiesBreakpointsDisplay.
•The System will list all the breakpoints.
•Select one or more breakpoint.
•Choose Delete individual .
Using the column header line, we can also change the sequence of the
fields we want to see. If we remove a field name from the column header
line, then the system deletes the field from the display. If we specify an
incorrect field name, the system displays a string of question marks.
Debugging
If the space you leave to display a field is too small , the system
truncates the display and indiates 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.
Note : The current list line is formatted only after completion (NEW-LINE).
Debugging
Replacing fields at Runtime.
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.
Debugging
To replace the value , we can do the following steps.
ABAP/4 writes the new value back to the program field or fields and the
system notes the change in the
system log. If we forget to click on the ‘R’ push-button , the system
ignores the values we entered.
Deleting a row
The line disappears from the table and the system adjusts the line
numbering accordingly.
Debugging
Editing a row
The functions Modify , Insert and append are field-specific in the
Debugger and can be carried out only one field at a time.
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 Modify.
3.Enter a new value for the field.
4.Choose Enter.
The system updates the line and displays the new contents in the table.
Debugging
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.
Debugging
.Switching to the ABAP/4 Editor
We can switch from the Debugger to ABAP/4 Editor at any time. If we
discover a program error during the debugging process , for example,we
can enter the ABAP/4 Editor to immediately correct the error in the
program’s code. We can also switch back to the editor in order to set new
static break-points.
After we set static breakpoints in the editor,they are not active in the
debugger when we switch back.We must re-generate the program.Then
the breakpoints appear in the debugger.
To return to the Editor for the program currently being debugged ,
Select Development-->ABAP/4 Editor.
Debugging
.Releasing the Database during debugging
During debugging, the system normally suppresses the COMMIT
statement. The COMMIT statement marks the end of a logical unit of
work(LUW).
As a result , the system locks up the database for the course of that
debugging session.
If we want to temporarily stop the program but do not want to end
session,we should release the database that in use.If we forget to release
this lock,no other user is able to modify data until we complete the test.To
release the database explicitly during break in testing , choose
Debugging -->Database -->Commit.
To undo all changes made in the database since the last COMMIT select
Debugging-->Database-->Rollback.