ABAP debugger : Introduction
I know what you are going to say. Generally speaking, the word "ABAP debugger" can be scary. In fact, what is this barbaric word? In reality, why ABAP debugger and how is it useful?
Actually, it comes from the English "To debug". Well, that doesn't help you much, I bet... OK.
To begin with, which consultant has never been faced with this:
Indeed, no doubt that the first time it happens to us, we are a little lost...
When a developer creates a program, despite all the help available, whether it be syntax checks or software checks during compilation, it regularly happens that everything is not perfect, and that certain problems have not been considered.
Thus, it is undeniable that the ABAP debugger is primarily a tool for developers, to help them avoid this kind of messages, which are called "Dump" . Indeed, it is a very important tool that allows to analyze ABAP programs to correct errors.
Nevertheless, we will see together how useful this tool can be for any SAP consultant and especially, we will see how to use it. Effectively, the ABAP debugger can also be used to analyze but especially to understand the already existing programs.
Moreover, it should be noted that SAP offers 2 debuggers: the classic one and its new version. Besides, we will only deal with this new version, available since SAP NetWeaver 2004.
First, let's go to the ABAP debugger interface. There are several ways to access it:
ABAP debugger : Access
In order to access it, you have to go to the transaction SE80: Repository Browser. Here you can select a program for example, then do :
By going to the SM37 transaction (Job overview), you can search for a job to simulate its execution in debug mode. To do this:
Concerning the different programs, methods, module functions, ... it is possible to launch the ABAP debugger by placing a Breakpoint. We will come back to this term a little later but simply, this point will launch the debugger when the program is executed
The next time the program is run, the debugger will open.
When you are in a transaction, specify /h and press "Enter".
SAP will then show you the following message:
ABAP debugger : Layout
So, here we are in our ABAP debugger. It looks like this:
1. Running the program
In fact, when the program is in "run" mode, a small yellow arrow indicates the current position you are in. It is important to know that at this line, the operation has not yet been executed.
Then, to move through the code, there are several ways:
Single Step
The next operation will be executed, then SAP will stop.
Keyboard Shortcut: F5
Execute
The next operation will be executed. Be careful, if the cursor is in front of a block (such as a routine, a module function, etc.), it will be fully executed. SAP will then stop.
Keyboard shortcut: F6
Return
The current block (such as a routine, module function, etc.) will be fully executed. SAP will then return to the code that called the executable block.
Keyboard shortcut: F7
Continue
Process the code until the next Break point / Watchpoint. If there is none / no more, the program will be executed in full and the debugger will close.
Keyboard shortcut: F8
Go to statement
It is possible to move to a specific location in the code. To move the cursor to the desired location, right click on the appropriate operation and choose: Goto Statement. Your cursor will then move to that location.
2. The different presentations / desktop
First of all, let's note that SAP offers the user several choices of presentation of the debugger. Indeed, we can distinguish 3 different Desktop, as well as a standard presentation. In fact, SAP will simply arrange the menus in a different way, depending on your choice. Here are 2 examples:
Desktop 1
Desktop 3
3. Variables area
In order to access the different variables present in the program, SAP offers this work area. Let's take a look at the different menus together:
4. The source code
To finish the presentation of the layout, let's quickly talk about the source code present in the debugger.
There is no doubt that this part is extremely important since it will always tell you where SAP is, what it intends to do next, which steps were skipped during the execution of the program, etc.
Thus, it is of primary importance for you to understand this area, and especially, to know how to move in it.
Based on this fact, SAP provides you with several tools. Let's see them together.
ABAP debugger: Breakpoint and Watchpoint
From now on, we will use these tools to force the debugger to stop at specific points. Let's start by defining these 2 notions:
Breakpoint
First, a Breakpoint is defined so that the program stops at that specific location. In fact, there are several ways to place a Breakpoint, but whichever way is used, SAP will stop at it when it runs.
Watchpoint
Second, unlike a Breakpoint used to stop at a specific point, a Watchpoint is used to monitor a variable. Thus, when the value of the variable changes, the debugger stops.
1. Breakpoint
In fact, there are several types of break points. Indeed, they can have several uses and several life spans.
Now let's see how to set a Breakpoint in order to stop the debugger.
Start by placing your cursor on the column to the left of the program line for which you want to insert a breakpoint and left-click.
In second place, still with your cursor, right click and choose the type of Breakpoint you want.
Third, while debugging, go to the menu for breakpoints.
This way you can choose where you want to place other Breakpoints.
2. Watchpoint
As seen earlier, a Watchpoint is used to scan for changes in a very specific variable.
Note that a Watchpoint can only be set during a debug session.
So, to create a Watchpoint, follow these steps:
Then a dialog box appears.
Afterwards, you must enter the variable to be analyzed. Once set, by using the keyboard shortcut F8 or the "Continue" button, SAP will run the program until the value of this variable changes, or until the program is terminated if it does not change.
ABAP debugger : Conclusion
By the end of this article, you will have had an overview of the possibilities offered by this extremely useful tool, the debugger.
Whether you are an ABAP developer or a functional consultant, it is essential that you have a thorough understanding of this tool.
In truth, we've only skimmed the surface of its features. In fact, it's one of the most complete programs on the market, and can be used for a whole host of other tasks.
Would you like unlimited access to our entire SAP training library? Test our training platform free of charge for a 7-day trial period.
Michael Antoine
SAP technical-functional consultant, WM (Warehouse Management) and eWM (extended Warehouse Management) expert.
Artur ABAP BLOG
Thank you for your article, it was useful. I add some info in video https://youtu.be/Z3DrxDoFSME maybe it also will be useful! Thanks!
keyusertraining@gmail.com
Thank you Artur for your comment and the useful resources you provide!