The question that we are going to cover today is: How to change values of variables when debugging an ABAP program in SAP debugger?
SAP debugger is a powerful instrument for analyzing the programs while they run. It enables developers to see what is going on inside the programs and find problems that are present in the code. One of the features of SAP debugger is the ability to change values of the variables “on the fly”. This feature is commonly used by functional SAP consultants when they have a hypothesis that changing the value of a particular variable will solve the problem that they are troubleshooting. Without this feature it would be necessary to modify the code to the program to test their hypothesis. Modification of the code is rather time and resource consuming process that also requires participation of an ABAP developer. On the other hand, changing values of the variables online in the debugger offers a fast and convenient alternative to the modification.
There are different types of variables that can be changed in SAP Debugger and we will discuss them in separate sections.
SAP Debugger: Changing Variable Values (Simple)
We start with the easiest type of variables: simple. The SAP debugger screen is shown on the screenshot below. The variable that we are going to modify is: HEADER_DATA-DELIV_NUMB. It is a simple variable and it contains a number of a delivery document in SAP. Currently it has the value ‘123456789’. Let us change it to ‘003456789’. For achieving this goal, it is necessary to double-click on the pencil icon located in the column after the value of the variable. The value field will become white and you will be able to modify the value of the variable in SAP debugger. The pencil icon will be replaced with the glasses icon. When you complete the editing of the value, it is necessary to press Enter button for exiting from the edit mode and saving the changes.
SAP Debugger: Changing Variable Values (Structure)
Next, let us see how to change the value of a structure variable. The key difference with the simple variables is that it is not possible to change the value of the structure on the same screen as shown above. There is simply no pencil icon next to the structure variable. For editing the structure variable, it is necessary to first drill down (navigate) to its components. You can do it by double-clicking the name of the variable. The system will take you to another tab with detailed overview of the structure you clicked on (see screenshot below). In this overview, you will find the pencil icons next to each component of this structure variable. These components can be edited in the same way as simple variables in the previous section.
SAP Debugger: Changing Variable Values (Table)
Finally, we are going to see how to change the value of a table in SAP debugger. It is the most complex case because tables may have multiple rows and multiple columns. Similarly to structures, you will not find the pencil icon next to variables of type table. It is necessary to double-click the name of the table for navigating to the detailed overview of the table. From the overview, it is possible to edit any field in the table but the process is a little bit tricky because there are no pencil icons anywhere.
For editing the existing content of the table, it is necessary to:
- Select the row in which the cell you wish to edit is located.
- Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
- In the Table Services window it is necessary to select Change Row Content command.
- All cells in the selected row will become available for editing. Perform your modification and save the changed by hitting Enter button.
For adding new rows in the table it is necessary to:
- Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
- In the Table Services window it is necessary to select Insert Row (Index) command.
- If there are existing rows in the table, the SAP system will offer you to use one of the existing rows as template. It is up to you whether to accept this offer.
- A new row will be added to the table and should be saved by pressing Enter button.
For removing a row from the table it is necessary to:
- Select the row that you would like to delete.
- Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
- In the Table Services window it is necessary to select Delete Rows command.
Final Remarks
It is possible that you may not be able to edit values of the variables in SAP debugger. The most likely and often reason of this problem is that you do not have authorization for editing the variables. You should contact your SAP security consultant and ask for assigning the required permissions.
In this post, we explained how to change variables’ values in SAP debugger. Our hope is that after reading this article you will easily answer any SAP interview questions related to using SAP debugger for modifying variables.