Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Caller method

Denis_Mller
Participant
0 Likes
1,579

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!

8 REPLIES 8
Read only

Ramneek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,549

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

Read only

0 Likes
1,549

ok, but what would be a good design for this problem?

Read only

ThomasZloch
Active Contributor
0 Likes
1,549

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

Read only

0 Likes
1,549

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.

Read only

0 Likes
1,549

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

Read only

0 Likes
1,549

Hi Dennis,

without discussing design questions you can use function module SYSTEM_CALLSTACK.

Regards,

Clemens

Read only

matt
Active Contributor
0 Likes
1,549

>

> Hi Dennis,

>

> without discussing design questions you can use function module SYSTEM_CALLSTACK.

>

> Regards,

>

> Clemens

As Ramneek Sharma said in the first response...

Read only

Former Member
0 Likes
1,549

This message was moderated.