SAP Debugger: Changing Variable Values

Advertisement

SAP DebuggerWith this post we are going to continue our series of SAP interview questions that you may encounter when interviewing for a new SAP job. The question that is going to be discussed today is related to using SAP debugger for analyzing custom developments (so called Z* programs and functional modules) and finding errors. Although it sounds like this question should be expected at the interviews for SAP ABAP developers, you will probably not encounter it there because this question is too easy for any ABAPer. On the other hand, you may expect this question on the interview for functional SAP consultants and its primary purpose is to test whether they have basic skills of using SAP debugger. Many people have an opinion that functional SAP consultants should have minimal understanding of ABAP and this point of view seems to be valid based on our experience of the real life SAP projects assignments.

The question that we are going to cover today is: How to change values of variables when debugging an ABAP program in SAP debugger?

Advertisement

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)
SAP Debugger: Find the simple variable which value you would like to modify

SAP Debugger: Change Simple Variable [Double-Click]
SAP Debugger: Double-click the pencil icon and the debugger will make the field editable
SAP Debugger: Change Simple Variable [Confirm]
SAP Debugger: Confirm the change by pushing Enter button

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: Change Structure Variable [Find]
SAP Debugger: Find the structure variable which value you would like to modify
SAP Debugger: Change Structure Variable [Edit]
SAP Debugger: Modify the required field of the structure by clicking the pencil icon

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.

Advertisement

SAP Debugger: Change Table Variable [Find]
SAP Debugger: Find the table variable which value you would like to modify
SAP Debugger: Change Table Variable [Detailed Overview]
SAP Debugger: Navigate to the detailed overview of the table
For editing the existing content of the table, it is necessary to:

  1. Select the row in which the cell you wish to edit is located.
  2. Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
  3. In the Table Services window it is necessary to select Change Row Content command.
  4. 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:

  1. Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
  2. In the Table Services window it is necessary to select Insert Row (Index) command.
  3. 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.
  4. 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:

  1. Select the row that you would like to delete.
  2. Click Services of the Tool icon on the right side of the window. A new popup window called Table Services will appear.
  3. In the Table Services window it is necessary to select Delete Rows command.

SAP Debugger: Change Table Variable [Table Services]
SAP Debugger: Table Services window
SAP Debugger: Change Table Variable [Modifying Table Content]
SAP Debugger: Modifying the content of the row

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.

Advertisement

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.

 

Leave a Reply

Do you have a question and want it to be answered ASAP? Post it on our FORUM here --> SAP FORUM!

Your email address will not be published. Required fields are marked *