Get Call stack history

Posted by

In a routine, when you need to get information about the calling subroutine / program, or the routine which called the routine which called…(etc…)… the current routine :-), common variables are storing this information and can be easily retrieved. They are SYSTEM() variables:

SYSTEM(1001): contains the very first called program/routine

SYSTEM(40): contains the current program (so equivalent to $APPLICATION).

SYSTEM(1029): contains all calling stack history, separated with VM and including return codes separated with SM.

Example:

Prog TEST.POD0 call TEST.POD call TEST.POD1 call TEST.POD2 :

When displaying the content of above SYSTEM() variables in the latest TEST.POD2

SYSTEM(40)   : TEST.POD2          = "current program"
SYSTEM(1001) : TEST.POD0          = "very first calling program"
SYSTEM(1029) :  3ü1ü7üTEST.POD1ÿ2ü1ü3üTEST.PODÿ1ü1ü3üTEST.POD0    =
3<SM>1<SM>7<SM>"calling program"
<VM>
2<SM>1<SM>3<SM>"calling program-1"
<VM>
1<SM>1<SM>3<SM>"calling program-2"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.