‎2011 Feb 09 10:18 AM
Hi
is there a way to read the caller method of my actual method?
I know that i can use a parameter but it is a third-party software.
Example:
Method A calls method C
Method B calls method C
Methode A and Method B are third-party and method C is my code.
Now i have to read in method C if the caller is method A or B.
Is there a way in standard? A SAP method?
Thanks for your help!
‎2011 Feb 09 11:32 AM
Hello Denis,
I suppose you could use the function module 'SYSTEM_CALLSTACK' to find the caller method. But I would like to add that this would be bad design and I would use it as the last resort only.
Thank you,
Ramneek
‎2011 Feb 09 11:36 AM
‎2011 Feb 09 11:37 AM
How does the third party software know that it should call your method C from their methods A and B? Exits, enhancement points?
Isn't there anything passed through that would let you make the distinction?
Thomas
P.S. good design is to not work with global variables or tricks like "SYSTEM_CALLSTACK", but rather have all necessary data locally available through the method interface.
Edited by: Thomas Zloch on Feb 9, 2011 12:38 PM
‎2011 Feb 09 11:49 AM
it was only an example. All methods are implemented by an third-party programmer in our system.
but we don't want to modify more than method C. If we modify method A, B, ... there is a high risk for this process.
‎2011 Feb 10 8:31 AM
Alternative would be adding and optional parameter where you pass caller name. This way you can adjust all the callers you need and leave those not relevant untouched. It isn't however good design as you make your callee in strong coupling with its callers. Imagine you add another caller, which entails modification of the callee (to interact with new method/object).
You should always program to [Loose coupling|http://en.wikipedia.org/wiki/Loose_coupling] even in relevance to different methods (not only objects). The more independent objects are the less modification their require. If you have method C built in a way it needs to distinguish which object/method it's worknig with, introduction of new similar method should probably be considered, or controlling that differentation on object level itself (i.e. by setting object's attribute).
Regards
Marcin
‎2011 Feb 11 5:01 PM
Hi Dennis,
without discussing design questions you can use function module SYSTEM_CALLSTACK.
Regards,
Clemens
‎2011 Feb 14 6:07 AM
>
> Hi Dennis,
>
> without discussing design questions you can use function module SYSTEM_CALLSTACK.
>
> Regards,
>
> Clemens
As Ramneek Sharma said in the first response...
‎2011 Mar 12 6:15 AM