Expand +



Software Testing and Development with the ABAP Debugger

by Dr. Joachim Jacobitz | SAPinsider

April 1, 2001

by Dr. Joachim Jacobitz SAPinsider - 2001 (Volume 2), April (Issue 2)

Debuggers are standard tools for developing and testing software. You can use them to test flows and field contents in programs at runtime, which makes them especially suited for error analysis in complex problems. When a program is executed, for example, you can test to find out whether or not a given data object contains a specific value. You can also follow the flow logic of a program, depending on the data object contents.

     Features like these make the ABAP Debugger an indispensable tool, not just for software development but also for consultancies and services that need to check on problems for their customers. The ABAP Debugger is an integrated component of the SAP development environment, with an interface that makes it easy to call and use a number of functions. It can be used for both functional and object-oriented programs, for individual reports, and even for complex Web transactions.

     You can call the ABAP Debugger in a number of ways:

  • From the Editor, by choosing Debugging
  • From the OK code, by entering /h
  • By setting a dynamic breakpoint
  • By inserting the Breakpoint statement in the source text
  • By calling System-> Utilities ->Debugging ABAP
Display Options in the ABAP Debugger

 After starting the ABAP Debugger, you can then call one of the various display modes using the pushbuttons, shown at the top of the screen in Figure 1.

Figure 1 ABAP Debugger

All the display modes have a similar design, in which the upper half of the screen contains the program text and the lower half contains the relevant information for that view.

     Figure 1 gives an example of one view of the ABAP Debugger in the fields mode. All in all, there are seven different standard display modes in the ABAP Debugger (see Figure 2 below).

 In addition to these modes, you can also select Goto -> Display data -> object for these additional views:

Display Mode Features
Fields Includes a scrollable field display that can display the contents of up to eight fields. The three most important system fields are also displayed.
Table Displays the contents of an internal table. You can also edit the entries in an internal table in this mode.
Breakpoints Scrollable breakpoint display with up to 30 breakpoints. You can also delete a breakpoint and define a breakpoint counter here.
Watchpoints Displays the current field values and conditions for which a watchpoint should be active.
Calls Displays the active event and call sequence up to the current breakpoint. The last active call is placed at the beginning of the list.
Overview Shows the processing blocks of a program and the relationship between program sections and events.
Settings Displays the current system settings and runtime warnings. You can change these settings with checkboxes.
Figure 2 Standard Display Modes Available from the ABAP Debugger
  • Single field: Displays the contents and technical attributes of a selected field.
  • Structured field: Displays the components of a structure, its contents, and its technical attributes. You can navigate to the detailed display by double-clicking on a component.
  • String: Displays the contents and current length of a string. You can also display part of the contents by defining an offset and a length (since Release 4.6).
  • Object: Displays the structure of an ABAP object (since 4.5).
Background on Breakpoints

A breakpoint will interrupt program execution at runtime at a certain location - for example, to check whether your program logic is correct. There are two types of breakpoints: static and dynamic.

     Static breakpoints are used only during the development phase of the application. The static instruction BREAK-POINT stops the ABAP processor at the marked location, no matter who the user is, while the break name instruction, below, sets a user-specific breakpoint, causing the runtime system to interrupt execution only if the program is started by the particular user (name):

if SY-SUBRC <> 0.
  break NAME.
  call method SET_X.
TIP:Because static breakpoints should be used only during the development phase of an application, they must be removed from the source text before the program is transported to a production system. You can find and delete breakpoints quickly in large programs by selecting Utilities-> Breakpoints. The enhanced program check also lists all the breakpoints in a source text.

     With dynamic breakpoints, on the other hand, the source text is not changed. Up to 30 breakpoints can be set dynamically, and can be created in the ABAP Editor in display and change mode, or directly in debugging mode. In both cases, you must place the cursor on the desired line before calling Utilities -> Breakpoints -> Set/delete.

     In debugging mode, you simply double-click on the relevant line, and the breakpoint is displayed as a stop sign next to the line of source text (Figure 3).

Figure 3 Breakpoints Indicated in Debuggin Mode

Setting Dynamic Breakpoints in Different Modules

After starting the Debugger, further options allow you to set dynamic breakpoints for specific cases such as:

  • Statements
  • Subroutines
  • Function modules
  • Methods
  • Exceptions
  • System exceptions

     After you choose one of these options, enter the data required, and then press Enter. The system confirms the breakpoint and adds it to the breakpoint display. When a system exception is triggered, a "warning triangle" is added to the line triggering the exception. By double-clicking on this warning triangle, you can view the internal name of the runtime error.

     By selecting the pushbutton Breakpoints or selecting Goto -> Control debugging -> Breakpoint, you can access the breakpoint display and management screen. The following functions are provided on that screen:

  • Display Breakpoints
  • Set a Startcounter
  • Delete a Breakpoint
  • Activate or Deactivate a Breakpoint

     Another feature of the Debugging mode is that you can also check Business Server Pages, where you can set and display breakpoints just as you can in ABAP programs. In addition, you can also take over breakpoints in Update and HTTP sessions.

     If you want to leave the Debugger temporarily, you can store your dynamic breakpoints by selecting Breakpoint -> Save. The breakpoints will be available again when you return to the Debugger. All breakpoints currently set in the defining program are saved and stay active until they are explicitly deleted.


A watchpoint is similar to a breakpoint - it is a stopping place in the program that tells the ABAP runtime processor to interrupt execution at a certain location in the source text. Like dynamic breakpoints, watchpoints are user-specific, so other users are not affected by the dynamic program execution. But in contrast to breakpoints, watchpoints only activate debugging mode when the field contents change. Watchpoints can be defined only in the Debugger.

     You can create a maximum of five watchpoints by selecting Watchpoints or by going to Breakpoint -> Create watchpoint. Individual watchpoints are defined either globally or locally, and you can use comparison operators to link them with a field or value:

Operator Meaning
= Equal to
<> Not equal to
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to

     If you create multiple watchpoints, you can link them with the logical operators AND and OR. To go to the corresponding screen, select Goto -> Control debugging -> Watchpoints. You can also display the watchpoints here by selecting Watchpoints. You can change or delete watchpoints here by left-clicking on the "Pencil" or "Garbage can" icon, respectively.

Using the Debugger to Review and Edit Source Text - From Data Objects to Tables

As mentioned above, all the display modes provided by the Debugger have the same basic structure: a section of the program source text is displayed in the upper half of the screen, as shown back in Figure 1. The lower part contains the field display with a maximum of eight scrollable lines.

     On the upper right of the ABAP Debugger screen, you will see a few buttons that adjust the screen display.

     With these buttons, you can make the program section larger and smaller by showing or hiding the field display. When you enter debugging mode, the source text of the program that was called is first displayed, and then the source text of the processing block currently being executed. The line that is currently being processed is marked with an arrow.

     Double-clicking on this button displays the line of the source text currently being processed.

     You can also go to any term by calling the "Find in source code" function or with Edit -> Find in source code.

     When you select Debugging -> Goto Statement, the system goes immediately to the line where the cursor is positioned. You can then easily navigate up and down within the source code. To position a line at the first location in the source text display, double-click on the first column of that line. You can scroll within the source text using the Up and Down keys, or by specifying line numbers. The source text of the program to be examined can be executed in these modes: Single step (F5), Execute (F6), Return (F7), or Continue (F8).

Editing Single Fields

The contents of program fields are displayed in the Debugger when you select Fields. You can enter a field name directly or select it by double-clicking on the field within the source text. Since only four of a maximum of eight fields are displayed, use the scrolling keys to view the other fields. The three most important system fields are defined automatically: SY-SUBRC, SY-TABIX, and SY-DBCNT (as you can see back in Figure 1). The following data objects are supported in the display:

  • Single fields
  • System fields
  • Structured fields
  • Strings
  • Data references
  • Object references
  • Internal tables
  • Objects

     The contents of more complex data objects, such as references or tables, are not displayed immediately in the standard display. For these, double-click on Field names with the left mouse key to go to the corresponding attribute display. The contents of external program fields can also be displayed if the name of the external program is defined in parentheses before the field names.

     Special forms of field display are as follows:

  • Character-like fields can be assigned an offset and a length. For example, if sy-datum+4(2) is entered in "Field names," the current month of the system date is displayed in "Field contents."

  • If an integer is specified in square brackets after the name of an internal table, e.g., itab[4], the contents of the line corresponding to the integer are output. In this case, the output would display the fourth line of internal table itab. If the value in brackets exceeds the number of current table lines, the table is marked as unknown.

  • As of Release 4.6, if there are data references, the contents of the referenced data object are displayed if an arrow and an asterisk are added to the name of the reference, e.g., r->*. This notation provides the contents of the field that is currently being referenced by data reference r.

  • As of Release 4.6, if you double-click on a data or object reference under "Field contents," all the attributes and field contents of the referenced data objects are displayed in the next screen. For object references, the attributes and values of the current instance of all referenced classes and interfaces are output. For example, 7 gives you all the values of the seventh instance of class cl.

  • As of Release 6.10, the headers of strings, internal tables, and data and object references are displayed with a prefixed asterisk. For example, the header of internal table itab is displayed in hexadecimal format if *itab is entered in the "Field names" column. The field only contains zeroes for tables that do not have a header.

  • As of Release 6.10, you can display the strings, internal tables, and data and object references in hexadecimal form by using an ampersand prefix. For example, &str will give you the reference to the string with the name str.

     The field contents can be displayed in either edited or hexadecimal format when the "Magnifying glass" icon is activated. You can delete all the field names with the "Garbage can" icon.

     You can also change the contents of certain fields at runtime to modify the program flow. To do this, you must enter the new value under "Field contents" and then confirm it with the "Pencil" icon.

TIP: Certain data objects, such as structures and internal tables, require you to double-click on the field names of the object to reach the attribute screen. Here you have to double-click on the individual fields again to call change mode. The Debugger then writes the new value in the program field and the system records the change in the system log. The values are copied in exactly the form in which they were entered. For this reason, you must take care with right-justified definitions of hexadecimal numbers and with uppercase or lowercase character strings.

Editing Structures and Internal Tables

In Table mode (in Figure 4), you can edit internal tables with flat and nested structures. As for the field display, you can make the display area larger or smaller using icons. Information about the table type, table key, and memory usage is also available.

     In Table mode, individual table lines are numbered sequentially, and can be moved horizontally and vertically using scrolling keys. If a valid line number is entered in the first column of the header line, this line is moved to the top of the display. The column name can also be changed in the header line, changing the order of the individual columns. Double-clicking on a column header moves the table display to the left, and the columns to the left of the selected column no longer appear in the display.

     The display format of the internal changes, like the field display, can also be changed. The field "Format" normally contains the value "E" to display columns with editing. This, however, can be replaced with "X" for hexadecimal or "C" for character display. The memory usage of the internal table is displayed by selecting Goto -> Display condition -> Memory usage.

     The Insert, Append, or Delete buttons at the bottom of the screen allow you to make line-by-line changes to the internal table from the ABAP Debugger. The contents of a table field can be changed by marking the relevant field and selecting Change. In this case, you can enter and overwrite values for the marked field, or you can double-click on the desired field and change the field contents in the next screen. Additional information, such as the type and length of the table field, are displayed in the Table view. Finally, for an overview of all the changes within a line, simply double-click on the line number.

Figure 4 The Table Mode in the ABAP Debugger

Attributes of Data Objects

     Attributes and contents of data objects are available in a separate screen segment in the Debugger by choosing Goto -> Display data object. Technical information, such as name, type, length, or contents, is displayed for:

  • Single fields
  • Structured fields
  • Strings
  • Internal tables
  • Objects

     You can obtain further information about the fields of a structure, table, reference, or class by double-clicking on these fields. For references, double-click on "Field Contents" to display the referenced object. If an attribute display contains a data object with an invalid data type, the correct display for the type appears automatically when you select Enter.

     There are a number of ways to check memory usage. First, by choosing Settings -> Memory Display On/Off, you can display the memory used by objects, tables, references, or individual fields. For a hit list of the 25 data objects that use the most memory, select Goto -> System -> System Areas. The system differentiates between allocated and referenced memory, and also displays the memory actually used for each data object. In Figure 5, the memory allocated and used is indicated for the data reference SEGMT.

Figure 5 Checking the Allocated and Actual Memory Used for Data Reference SEGMT

     Field contents can be manipulated in much the same way as the field display. You can change the field contents, display them in hexadecimal format (using the single-field display mode), and show and hide substructures (using the structured-field display mode).

Editing Objects

As of Release 4.6, to output attributes of classes, interfaces, and instances, select Goto -> Display data object -> Object and specify the object identifier. Alternatively, double-click on the object reference in the source text. In the screen that follows (Figure 6), you can mark the attributes and visibility ranges for the required display. The attribute names, with their contents, data type, and length, are displayed when you select the "Filter" icon.

     If an attribute is a reference to another object, the attributes of the referenced object are displayed by double-clicking on the contents of the object. If the name of a class is entered in the "Object name" field in the form , as in Figure 6, the static attributes of this class are displayed without requiring an instance.

     Other features allow you to view a single field display or restrict the listing of attributes. For instance, to go from here to a single-field display, simply double-click on the name of the attribute. Or, double-click on the name of an interface listed, and you can restrict the display listing to the attributes for the selected interface. If the cursor is placed on a field name containing an object reference in the field display of the Debugger, the menu Goto -> System -> Find reference gives you all the locations that refer to this object.

Figure 6 Displaying Data Object Attributes in ABAP Debugger

     The event display gives an overview of all the events belonging to an object and of the registered handlers. Select the Events button to list all the events belonging to a given object (see the Event display example in Figure 7). The identifiers for all registered handlers for an event are defined under "Handling object," and the corresponding handling methods called for this event are also defined.

     In addition, if you enter the name of a class in field "Object name" in the form and then select Events, the handler methods and the objects of all the static events are displayed. You do not need an instance here.

Figure 7 The Event Display

Other Functions

The ABAP Debugger supports class-based exceptions, display of list, decoupling from the database, and navigation to other development tools like the ABAP Editor or the Object Navigator. You can set the Debugger mode and the system's behavior when a warning from the kernel occurs by choosing Settings in the ABAP Debugger. The following modes are included:

  • System Debugging
  • Update Debugging
  • In Background Task: Do not process
  • Automation Controller
  • Memory Monitoring
  • Runtime Warnings

     By selecting Goto, you can find more details about the internal work of the Debugger, such as active call stacks, events, control blocks, or system areas. By selecting Goto ' Kernel Debugging, you can follow the internal behavior at operating system level - for example, to check that processors are working correctly.


With these functions, the ABAP Debugger offers a variety of options for checking the runtime behavior of programs quickly and effectively. The user interface is standardized and is thus easier to use, so that you can work more intuitively. There are also many different navigation options, which give you a better overview of programs and make connections clearer. Thus the ABAP Debugger - along with SAP's other testing tools - is one of the most important tools available for developing, maintaining, and troubleshooting your ABAP programs.

Dr. Joachim Jacobitz joined SAP AG in 1987. After 10 years as a software developer for Shop Floor Control, he now works in Business Programming Languages, where he is mainly involved in testing, documentation, and customer training. He can be reached at

An email has been sent to:

More from SAPinsider


Please log in to post a comment.

No comments have been submitted on this article. Be the first to comment!