2024 Jul 07 8:35 AM
Today, a friend asked me about the meaning of the "Variables Checkbox" in the ABAP debugger, as shown in the image below:
The friend was referring to the Save and Load functions in the Debugger Session of the ABAP debugger:
To be honest, although I am quite familiar with the ABAP debugger, I have never used this particular function.
The Load and Save menus appear as a pair, which likely means they are meant to handle the persistence of the ABAP debugging session. This would involve saving the various settings and values of the current session to some storage medium and later reloading and restoring these saved values from that medium.
When you click Save, a dialog box appears, divided into three sections.
Section 1 specifies the storage medium for persisting the debugging session, whether to save it to a local file or to a table in the ABAP system database.
Section 2 specifies the Technical Name of the stored session.
Section 3 specifies which properties of the current session need to be persisted.
Both my friend and I were puzzled by the Variables checkbox in Section 3.
What does this option mean? If checked, does it mean that the content of the variables in the current debugging session will also be persisted?
My first instinct was that this was unlikely.
Imagine a debugging session where we use OPEN SQL to read a large amount of data into an ABAP internal table variable from a database table.
If the save function of the ABAP debugging session also persisted the content of the ABAP variables in the current session, it would consume too much storage space.
Of course, this is just my guess.
To verify it, we need to find evidence.
We could check the SAP official help documentation.
But I prefer the method: Talk is Cheap. Show me the Code.
Click the Variables area with the mouse and press F1.
In the pop-up dialog box, click Technical Information:
Then you will see that the Variables checkbox in the save session dialog corresponds to the field named VARIABLES in the ABAP report program SAPLSTPDA_DEBUG_SESSIONS, Screen number 0100.
So, there is no need to spend effort looking up documentation. Just look at the source code to understand the function of this field, right?
We open the ABAP program found above in SE80, locate Screen 0100, and see that the PROCESS AFTER INPUT on line 8 is responsible for handling user input.
In line 26, the subroutine user_command_0100 contains the code I want to check.
Double-clicking line 26, I find it calls another subroutine ok_code_handling.
So, continue double-clicking:
Line 20 enters the corresponding branch according to the OK Code.
For the Save operation, the logic is encapsulated in the save_session method of cl_tpda_debug_session_handler.
Double-clicking this method, I search for the field VARIABLES, as found through F1 earlier, and find an IF branch.
This branch includes the cl_tpda_variable_manager, which, judging by the name, is responsible for managing variables in the ABAP debugging session.
Double-click to enter this class.
These methods with DB in their names include the logic for CRUD operations on variables in the ABAP debugging session at the database level.
Opening one method randomly, I finally find the TPDA_VARIABLES table. This table is where variable information in the ABAP debugging session is stored when selecting persistence at the database level.
I wrote a random ABAP report and checked the values of three variables, cv_data, lv_s, and lt_content, in the debugger Variables window, then used the Debugger Session->Save function to save the current session along with the variable information:
When saving, remember to check the Variables Checkbox and name the session var_test.
After successfully saving, query the TPDA_VARIABLES table with the name var_test and find that the variable information in the debugging session is stored in XML format in this table.
Let's check the specific content of the XML.
The truth is revealed.
Conclusion: When the Variables checkbox is checked, the ABAP debugger will only persist the names of the variables currently being viewed in the Variables panel. The actual content of the variables will not be saved.
The following image shows the ABAP debugger before selecting the Load function, with the Variables area empty.
After selecting Load, the variable names saved in the database table automatically appear in the Variables area.
When debugging a very complex ABAP program, if you need to check multiple variables at once but need to interrupt the debugging for some reason, you can use the Save - Load function to save the names of the variables you are viewing for future restoration.
This article introduces another example of verifying one's guesses by reading the source code to figure out how the standard functions provided by the system work.
Thanks a lot for reading my post 🙂
2024 Jul 07 1:41 PM
Thanks. Shouldn't it be published as a blog post rather than a discussion? (Technology Blogs by SAP | SAP Community)