ABAP Quick - Callstack
Sometimes you want to know where you stand or just to make sure that the program or the method was called at the right time? We help you out with this simple implementation.
There is a simple function module in the system for reading the current callstack. With SYSTEM_CALLSTACK you get the current call for the currently running code.
The implementation as the following example:
DATA lt_stack TYPE abap_callstack. " Get the actual callstack CALL FUNCTION 'SYSTEM_CALLSTACK' EXPORTING max_level = 0 IMPORTING callstack = lt_stack.
As a result, you get a table with the most important information, such as:
- Code line
As the documentation of the function modules describes, only the exporting parameter callstack should be used, since it also contains all the information and the parameter et_callstack is obsolete.
If all information is needed, the level remains at 0. If only the last x-levels are needed, for example because the position is called in a standard program or a user exit, then a small number of the last calls is sufficient.
With the simple function module you can implement many checks and features in a large application or implement security features. Your imagination knows no bounds.