Search code examples
abapcallstacksap-hr

Strange prefix (/A\) in ABAP call stack


Generally I try to make my questions Reproducible. In this case I couldn't find a way. Please feel free to guide me how to grab more details and I will attach.

In some cases, we are using the ABAP call stack programmatically to get additional info. I.E: logging user calls, accessing variables from lower calls in the stack as a last resort when there is no other proper way to retrieve them.

We have encountered a case, in which weird chars were added as a prefix in the call stack for central programs of HR module 'MP9XXX00'(Module-Pool generated programs for customer-specific PA infotypes). The weird chars are /A\. The full string for calling program is /A\MP9XXX00.

The code used to get the whole call stack:

lt_call = cl_abap_get_call_stack=>format_call_stack_with_struct( cl_abap_get_call_stack=>get_call_stack( ) ).

There aren't such programs /A\MP9XXX00 in SE80.

Also, when tried to receive variables from calling program as mentioned, like this: ASSIGN |( { ls_call-prog })PSYST| it failes, it caused dump. And when we looked into ST22 the stack didn't contain any /A\MP9XXX00 but just MP9XXX00 (ls_call-prog contained /A\MP9XXX00).

As said, we didn't manage to reproduce and debug it. just saw the result.

Where could those chars come from?

What we thought of

  1. We thought that it might be related to the fact that our customer namespace starts with /A, but still, why it's shown up? why just a few times? why just the first two characters? and where did the other \ come from?
  2. We thought that the prefix /A\ might be temporary added to (those) program names, say while importing related transport requests. And that maybe A is for Active/Activating. What made us think so is that it happens more in QA than in production.

Solution

  • With CL_ABAP_GET_CALL_STACK, /A\ are normal characters part of the internal/unformatted data of the ABAP call stack (method GET_CALL_STACK) and it must be formatted so that to remove /A\ (methods FORMAT_CALL_STACK or FORMAT_CALL_STACK_WITH_STRUCT).

    Here are the three ABAP call stack representations, of course FORMAT_CALL_STACK_WITH_STRUCT is the easiest to use:

    Backend Two-Process ABAP Debugger with 3 Tables of formats of CL_ABAP_GET_CALL_STACK

    Result of GET_CALL_STACK:

    • PROGRAM_INFO (100 characters)
      • 1-3 (3): "/A\"
      • 4-43 (40): main program
      • 44-67 (24): timestamp of the ABAP Load generation of the main program (concatenation of TRDIR-UDAT and TRDIR-UTIME) and Offset to the Processing Control Block (the CONT block of the ABAP Load, as can be seen in the ABAP statement LOAD REPORT), separated by backslash (e.g. \20180413155837\2128\
    • EVENT_INFO (100 characters)
      • 1-3 (3): "/A\"
      • 4-43 (40): include program
      • 44-70 (27): timestamp of the ABAP Load generation of the include program (concatenation of REPOSRC-UDAT and REPOSRC-UTIME) and two unknown numbers used to determine the eventual local class name (possibly the index of the TRIG block line of the ABAP Load), separated by backslash (e.g. \20180413155837\00033\9\)
      • 71-90 (20): event/procedure
    • MODULE_INFO (20 characters)
      • EVENT
      • FORM
      • FUNCTION
      • MODULE (PAI)
      • MODULE (PBO)

    Result of FORMAT_CALL_STACK (lines of type STRING):

    • 1-5 (5): stack depth
    • 6-6: space
    • 7-26 (20): procedure type ("MODULE (PAI)", etc.)
    • 27-27: space
    • 28-67 (40): main program
    • 68-68: space
    • 69-108 (40): include program
    • 109-109: space
    • 110-114 (5): line number in the include program
    • 115-115: space
    • 116-208 (93): event/procedure (e.g. LOCAL_CLASS_NAME_30=>INTERFACE_NAME_30~METHOD_NAME_30)

    Result of FORMAT_CALL_STACK_WITH_STRUCT (lines with 6 components):

    • STACK_DEPTH (integer)
    • KIND (30)
      • EVENT
      • FORM
      • FUNCTION
      • MODULE (PAI)
      • MODULE (PBO)
    • PROGNAME (40): main program
    • INCLUDENAME (40): include program
    • LINE (integer)
    • EVENT (61): event/Procedure (name of event, function module, method, subroutine)

    ABAP code for the test:

    REPORT zzsro_test01.
    PERFORM my_subroutine.
    FORM my_subroutine.
      DATA(unformatted_call_stack) = cl_abap_get_call_stack=>get_call_stack( ).
      DATA(formatted_call_stack) = cl_abap_get_call_stack=>format_call_stack( unformatted_call_stack ).
      DATA(structure_formatted_call_stack) = cl_abap_get_call_stack=>format_call_stack_with_struct( unformatted_call_stack ).
    ENDFORM.