How to get the program call stack trace?
You may try SYSTEM_CALLSTACK
.
DATA:
abap_callstack_line TYPE abap_callstack_line,
callstack TYPE abap_callstack.
CALL FUNCTION 'SYSTEM_CALLSTACK'
EXPORTING
max_level = 4
IMPORTING
callstack = callstack.
But in your case I would prefer an additional parameter and the calling place can fill this entry. I would not call the parameter called_by
but something like behaviour
or mode
.
vlad-ardelean
Currently: Python backends + some experimenting with react Previously: ABAP, Java EE, C# I'm just another physics major that ended up in programming. I m trying to be as sciency as I can about computer related stuff...sometimes it helps.
Updated on August 14, 2022Comments
-
vlad-ardelean over 1 year
My program can be started in 2 ways:
the
START OF SELECTION
event that calls aMAIN
function from one of my local classes. theZAVGTTA4
transaction that calls the same method.at
PAI
, for the BACK event, when callingLEAVE TO SCREEN '0'.
, my program behaves in 2 ways according to how it was started. I want to get back to the selection screen (1000).I thought about querying the stack, where i'm sure to find how my program was called. I can see that the stack trace is different, but i don't know how to acces my stack from the program. I've heard about the RTTI that i think might be able to help me.
-
vlad-ardelean almost 12 yearsThx. that did it. Btw, with your explanation, do you mean that some data object called "behavior" be declared in the 'DATA' section, and some piece of logic be implemented? Cuz that's what i did. But if you meand something different (and you think it's really nice to explain :P ) please provide some more details. Anyway thx alot!
-
knut almost 12 yearsI have some problems to give a correct example, because I did not really understand, how you call what. What are the two ways to call your programm? Via submit and with transaction
ZAVGTTA4
? The system fieldSY-TCODE
contains the actual transaction. IfSY-TCODE = 'ZAVGTTA4'
, then your programm is called with transactionZAVGTTA4
. -
Jorg almost 12 yearsI know it's already answered but I'm wondering what the value of variable
SY-CPROG
is too (that's calling program name). -
knut almost 12 yearsThere is also
SY-REPID
- the program name. I have no SAP-System available, so I can't check it, but I thinkSY-REPID
is the actual report (called bySA38
or direct per transaction). If you make make submits,SY-CPROG
is the report "one level lower",SY-REPID
is the first report.