04-08-2014 12:46 PM
Hi,
I have a "twisted" requirement, which I cannot reject as unfeasible, and where I don't see a way to implement it without programming a wild "dependancy" on the context in which my logic will be called: "am I called in IS-U Print Document Display functionality call chain?". Does anyone know what is SAP's attitude towards using cl_abap_get_call_stack - i can't find a single use outside a testclass in ABAP 702, SAP ERP 605 System, but it does seem to function well. Has anyone experience using it? Has anyone a better alternative (looking at sy-cprog or sy-tcode will certainly not cut it).
Thank you,
Janis
04-08-2014 1:13 PM
Hi,
I'm not sure what you want but maybe this code will help you:
DATA: xt_ctm_rfc_call TYPE sys_callst. "Callstack Table
DATA: xs_ctm_rfc_call TYPE sys_calls. "Callstack Line
CLEAR xt_ctm_rfc_call.
CALL FUNCTION 'SYSTEM_CALLSTACK'
IMPORTING
et_callstack = xt_ctm_rfc_call.
LOOP AT xt_ctm_rfc_call
INTO xs_ctm_rfc_call.
* do something
ENDLOOP.
Regards,
Klaus
04-08-2014 12:50 PM
Hi,
You could try to filter down on the exact business requirement which led to this technical requirement.
It is indeed a bit strange and it is hard to see the added benefit to the business with this one.
Good luck!
Kind regards, Rob Dielemans
04-08-2014 1:13 PM
Hi,
I'm not sure what you want but maybe this code will help you:
DATA: xt_ctm_rfc_call TYPE sys_callst. "Callstack Table
DATA: xs_ctm_rfc_call TYPE sys_calls. "Callstack Line
CLEAR xt_ctm_rfc_call.
CALL FUNCTION 'SYSTEM_CALLSTACK'
IMPORTING
et_callstack = xt_ctm_rfc_call.
LOOP AT xt_ctm_rfc_call
INTO xs_ctm_rfc_call.
* do something
ENDLOOP.
Regards,
Klaus
04-08-2014 1:20 PM
This class is too young, but good old FM SYSTEM_CALLSTACK is somehow often used for test like 'called from BAPI' or such requirement.
Regards,
Raymond
04-08-2014 1:32 PM
I'm also hesitant about using the call stack and check for module names etc., since this logic might not survive the next major upgrade.
Two alternatives for finding out "where do I come from" could be:
Thomas
04-08-2014 1:57 PM
Yes, that would be my first choice too - enhance the SAP Functionality (FM) with my singleton that sets a flag on entry, check the flag down the call chain where I need to know. The trouble is - in this particular case, I absolutely must make sure my flag gets reset on leaving SAP FM and I can't "handle" exceptions of FM, can I..?
cheers
Janis
04-08-2014 1:41 PM
You are right, of course, and I'm merely trying to deal somehow with consequences of wrong decisions on how a whole block of business requrements should (not) have been implemented. Unfortunately, I can't dream of "redoing it right" - that will be man-months of effort for no identifyable business of functional gain.
& Thank you, that FM looks much more encouraging.
cheers,
Jānis