Troubleshooting ABAP code errors

Need to display information to help diagnose an error with ABAP code? Learn how in this tip from a SearchSAP.com contributor.

Often when an error occurs in your ABAP code, it would be helpful to display how the error occurred, in which routine or method the error occurred and how you got to this routine.

Use function SYSTEM_CALLSTACK to display the call hierarchy (for example, in error handling). Using this function, you can show this extra information to help analyze the problem. This function works on a Basis system -- version 4.6 C or higher.

 
REPORT zz_system_callstack.
* Example of using the system callstack function
DATA: ta_callstack TYPE  sys_callst,
      wa_callstack LIKE LINE OF ta_callstack.

START-OF-SELECTION.

  PERFORM call_routine_1.

*&--------------------------------------------------------------------*
*&      Form  call_routine_1
*&--------------------------------------------------------------------*
FORM call_routine_1.

  PERFORM call_routine_2.
ENDFORM.                    "call_routine_1
*&--------------------------------------------------------------------*
*&      Form  call_routine_2
*&--------------------------------------------------------------------*
FORM call_routine_2.

  CALL FUNCTION 'SYSTEM_CALLSTACK'
    IMPORTING
      et_callstack = ta_callstack.

  LOOP AT ta_callstack INTO wa_callstack.
    WRITE: / wa_callstack-progname,
             wa_callstack-eventtype,
             wa_callstack-eventname.
  ENDLOOP.
ENDFORM.                    "call_routine_2

The output will look like this:
ZZ_SYSTEM_CALLSTACK                      FORM         CALL_ROUTINE_2

ZZ_SYSTEM_CALLSTACK                      FORM         CALL_ROUTINE_1

ZZ_SYSTEM_CALLSTACK                      EVENT        START-OF-SELECTION
This was first published in December 2005

Dig deeper on SAP ABAP

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close