ATS App. Prog. – ABAP Programming Module Presentations When should debugging be used? When a program is syntactically correct but has logical flaws When actual results do not match expected results When component testing a program Anytime detailed examination of source code logic is required
Several options exist for debugging a program: Start the program using the Debugging function (from the ABAP Editor initial screen, select either the Debugging pushbutton, or via menu option Program -> Execute -> Debugging From the Repository Browser’s object list, use the menu option Development Object -> Test/Execute and then select Debugging from the pop-up dialogue box. From any screen, select Systems -> Utilities -> Debug ABAP. From any screen, type /h in the system command line and press ENTER. Set break-points in the program and execute it normally. When the break-point is encountered, the program will enter the debug mode.
The pushbuttons across the top of the screen provide links to other debugging information and will be discussed throughout this Module. The source code window displays the statements currently being executed or may be used to scroll through the code to set breakpoints. Breakpoints are identified with a stop sign and will be discussed in detail later in this Module. The field evaluation window displays the value of selected fields.
When entering the debugger, there is a choice of seven different views: Fields - displays the field’s content and technical characteristics Table - displays the contents of an internal table Breakpoint - interrupts a program at a given line of code. Breakpoints can be static or dynamic. Watchpoint - interrupts a program only when there is a change in the contents of a particular field or filed string. It is possible to define multiple watchpoints, attach conditions to them, and link two or more watchpoints using a relational operator. Calls - displays an active event chain and the call sequence up to the current breakpoint. The most recent active call appears at the top of the list and the previous calls appear underneath. Overview - displays the structure of the programs being debugged. This view shows the event names and event types within a program and indicates which section is currently being used. Settings - displays the different options and error handling a user has when debugging
ATS App. Prog. – ABAP Programming Module Presentations To display the value of a particular variable, double-click on the variable, which will copy it to the field evaluation window. The variable name may also be typed directly in the Field names column of the field evaluation window.
While executing the program in debug mode, the value of a field may be modified. Once a field has been selected and the corresponding values are displayed in the field evaluation window, the field value may be manually changed in the Field contents column. The Change pushbutton (pencil icon) should then be selected to activate the field value change.
There are different methods of setting breakpoints for a program: ABAP Editor Position the cursor on a program line. Save the breakpoint by selecting Utilities -> Break-points -> Set Or, use the ABAP statement BREAK-POINT to set breakpoints in the program. You can set personalised breakpoints using the statement BREAK USERNAME. Debugging mode Position the cursor on a program line. Set a breakpoint with F2, double-click, or select via Break-point -> Set/ Delete. The breakpoint at function allows you to set breakpoints at strategic points in the program code. The breakpoint button displays an overview of the breakpoints that have been set within the program.
A watchpoint is a signal within a program’s code that tells the ABAP runtime processor to interrupt a program at a particular point in the code. Watchpoints are set from the debugger. Set and remove watchpoints as needed. Watchpoints are field-specific. Use a watchpoint to observe the changes to a particular field. The debugger interrupts the program when the field’s contents change. Watchpoints can be set either locally and globally. Global watchpoints are valid in all programs that are called. Local watchpoints are only valid within a specified program. Watchpoints: Up to five watchpoints can be defined Conditional watchpoints can be defined using <, <=, =, <>, >=, > Watchpoints can be combined with AND or OR Local and global watchpoints (i.e., stop only in my program) can be set defined. Menu from Debugging mode: Watchpoint -> Create Watchpoint.
The contents of internal tables may be displayed by selecting the Tables pushbutton at the top of the Debugging screen.
Module Objectives <ul><li>Define debugging </li></ul><ul><li>Describe branching to debugging mode </li></ul><ul><li>Define key debugging concepts and functions </li></ul><ul><li>Explain the debugging mode </li></ul><ul><li>Describe examining/changing variables </li></ul><ul><li>Identify breakpoints and watchpoints </li></ul><ul><li>Debug internal tables </li></ul>
What is Debugging? <ul><li>Tool used to identify and eliminate errors in ABAP programs </li></ul><ul><li>Allows the verification of program logic in a step-by-step manner by examining the results of individual statements </li></ul>
Branching to Debugging Mode Program ... . Breakpoint ... . ABAP Editor ABAP Debugger Debugging Program B170D051 Breakpoints Object List Development object ... ... ... . . . Test/execute . . . Any screen ... ... ... System Help . . . Utilities . . . . . . Debug ABAP . . . /h
Key Debugging Concepts <ul><li>Debugger modes </li></ul><ul><li>Examining the value of variables </li></ul><ul><li>Changing the value of variables </li></ul><ul><li>Setting breakpoints </li></ul><ul><li>Setting watchpoints </li></ul><ul><li>Viewing contents of internal tables </li></ul>
The Debugging Display ABAP Debugger Watchpoint f Z C C Table Breakpoints Watchpoints Calls Overview Settings Fields Main Program Source code of EVENT START-OF-SELECTION where matkl = c_matkl. Loop at i_tab. v_counter = v_counter + 1. at new vbeln. write:/ i_tab-vbeln color COL_HEADING. ENDAT. write: /10 i_tab-posnr, i_tab-arktx. endloop. ZZXXXXX ZZXXXXX I_TAB-VBELN 0001234 + /
The Most Important Debugging Functions Single Step Execute Continue Table Breakpoint Watchpoint Return Hexadecimal display Replace Processes the next program line Allows the change of data contents during debugging Processing continues until the next breakpoint (or end of program) is encountered Displays the contents of internal tables Displays data in hexadecimal format Interrupts the program when there is a change in a field Identifies breakpoints Executes all processing steps belonging to one statement Returns from a routine
Setting Breakpoints Menu: Keyword: Utilities -> Breakpoints BREAK-POINT Line selection (double-click) Breakpoint pushbutton Menu: ABAP Editor Debugging Mode Breakpoint -> Create/Delete Activate/Deactivate Delete All Deactivate All Save Breakpoint At Create Watchpoints
Watchpoints Debugging .. Breakpoint .. ABAP Debugger Watchpoint f Z C C or Create/Delete .. .. .. Create Watchpoint