This is a test message to test the length of the message box.
Login

ABAP Quick - Callstack

1066

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.

 

Example

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:

  • Program/include
  • Code line
  • Blocktype/-name

 

ABAP debugger callstack

 

Parameter

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.

 

Conclusion

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.


Included topics:
QuickCallstack
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP in Practice - String Processing

Category - ABAP

In this practical example we look at the string processing to determine the CDS names in CamelCase and how you can implement this with ABAP.

10/15/2024

ABAP in Practice - Test Driven Development

Category - ABAP

How does TDD actually work in practice and are there simple examples for learning in ABAP? In this exercise we will look at the practical part.

09/24/2024

ABAP in Practice - Merge data sets

Category - ABAP

How do we merge two different data sets in ABAP, especially with regard to Modern ABAP? A practical task for this topic.

09/17/2024

ABAP in Practice - Modern ABAP

Category - ABAP

In this small task we look at existing classic ABAP source code and try to optimize it according to Modern ABAP.

08/27/2024

ABAP Quick - Performance Data Filtering

Category - ABAP

Which statement do you use in ABAP to filter internal tables and is it performant? Read more in this article.

08/13/2024