Book Extract – Introduction To Using The SAP ABAP Debug Tools

Beginners Guide To ABAP

Available on Amazon

This chapter will introduce the ABAP debugger, and will introduce some of the tools which can be used to ensure that the programs you create function as intended. It will also show ways to highlight logic bugs in programs that cannot be identified by the syntax checker. You can also take a look at another article showing How To Use The SAP ABAP Debugger Efficiently and taking things a step further with SAP ABAP Debugger Scripting.

The first step here is to load a program which has been used previously, and which accesses the database table which has been created regarding employee records. If you have been following along with instructions, load program “Z_Employee_List_01” into the ABAP Editor.

The program contains a number of SELECT loops, which in turn write the contents of the table being read to the output screen in several ways, separated by ULINE statements:


Having examined the code, return to the front screen of the ABAP editor.

Firstly, on this screen you will notice there is a ‘Debugging’ button in the toolbar (also accessible with SHIFT+F5):



Click this with the program name in the program input text box to start a new debugging session. When this opens, a blue arrow should be visible, pointing at the first line of code in the program:



An alternative way of starting a debugging session is to display the code itself from the initial screen, select a line of code and set a breakpoint. This is done by, having selected a line, clicking the Stop icon.

This sets a breakpoint for that line. When the program is then executed the execution will pause highlighting the line that has the Breakpoint set entering the debugging session. Usually, this is the easiest method to use, as one will often have a good idea of where the issues in a program are allowing you to focus on specific areas of code straight away, rather than starting from the very beginning of a program as the previous method does:



There are two types of breakpoint which can be set in a program. Static (which will be examined later) and dynamic. A dynamic breakpoint is the kind which was used above, and these are only valid for the current session. If one leaves the SAP GUI and returns later, any dynamic breakpoints set will no longer exist. A breakpoint can also be set by double-clicking any statement within the debugging session itself. To then remove these in the session, simple double-click the stop icon appearing adjacent to them.

You will notice that a number of buttons appear at the top of the debugging screen:


These buttons allow for different modes of the ABAP debugger to be entered. The default mode here is Fields.

The ‘Single step’ button, the first on the left in the row above the modes, also accessible with F5, allows one to go through the code within the debugger line-by-line, or indeed as its name would suggest, single steps. As one presses the button, the blue arrow on the left of the code will move down one line at a time.

The next button along is the ‘Execute’ button, with a shortcut of F6. This allows for independent sections of code to be executed, such as function modules or forms. This can be very useful. If a program includes existing sections of code already created in an SAP system which are known to be correct, there is no need to debug them. These can then be executed independently, while other parts are debugged to find specific problems.

The next button is the ‘Return’ function (F7). This can be very useful if one forgets to use the ‘Execute’ function. If one goes through the lines of a program step-by-step, using the F5 key to step into a working function module, which may contain many lines of code, it is likely the case that it does not need to be debugged (because you know this function module already exists). Pressing the F5 key endlessly to go through the lines of code here is unnecessary when one wants to step out of this function module and access the parts which require debugging. Using the ‘Return’ button, all of the code within a specific function can be executed, returning to the line of code which calls that function.

The fourth in the row is the ‘Continue’ option (F8). This allows one to continue the program without going through step-by-step, line-by-line. When this button is pressed, the program executes and the output screen is shown. This button can also be used to just access a selected line of code, where the cursor is positioned. If one positions the cursor in a line of code and presses continue, the blue arrow in the debugger will appear directly next to that line. If you then press continue again, the program will be executed.

The next option in this row of the toolbar is ‘Display list’, accessible with CTRL+F12. This takes you to the output screen as it currently stands within the debug session. Here, the code has been executed to output the result of the first SELECT statement in the program:


This function allows you to see the results of the reports whilst the program is in mid-flow.

The last option here is ‘Create watchpoint’ (SHIFT + F8). Watchpoints will covered in another article.



About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon