Hi Tomas,
as Chris already stated, unfortunately PB doesn't offer access to the stacktrace during runtime and this has been an enhance request for serveral years. But meanwhile you may want to consider trying a third party tool called "fastfuncs". Among some high performance string manipulation methods it provides you a method that retrieves the current stacktrace as an array. You might need to use Visual Studio (or maybe SnapDevelop?) to replace the PBxxx.dll references and recompile the dll to match your version of PowerBuilder. As I remember right, you just need to modify the additional dependencies of the release to the PB version you are using. (see screenshot)
We have been using it in out applications developed in PB2017R2 and PB2019R3 for some time now and it works like a charm.
Check out the git page: https://github.com/lakeman/fastfuncs
In PB you would declare it as an external function, eg.:
SUBROUTINE GetCallstack(REF STRING as_call_stack[]) SYSTEM LIBRARY "fastfuncs190.dll" ALIAS FOR "Stack_Trace"
Finally in your code you can call something like
string lsa_callstack[]
GetCallstack(lsa_callstack[])
to receive the current stack trace.
See the attached screenshot as an example. Hope it fits your needs.
Best regards,
Marc
Still it would be great to have this as a built-in functionality coming with future PB releases, so we do not need to rely on third-party software when it comes to PB core routines.