2015 Apr 15 2:38 PM
Hi all,
I know static methods cannot be redefined, but they can be called using a subclass as the 'calling class name'. Is it possible to determine the object type used for calling a static method?
For example, I have ZCL_SUPER with a static method HELLO and a subclass ZCL_SUB.
I can use ZCL_SUPER=>HELLO( ) or I can use ZCL_SUB=>HELLO( ).
Both will execute the same code (correct), but is it possible to tell the difference inside the HELLO method? SY-REPID will always show the superclass (also correct).
I've found some similar threads but none with a clear answer.
Any input appreciated,
Mike
2015 Oct 23 7:41 AM
I guess there is no simple solution. I expect that the compiler interprets the symbolic names ZCL_SUPER=> and ZCL_SUB=> in order to point to the method and forgets about it. Why should it keep the information? In fact I have a similar problem: Is there a simple way to find out the name of an actual parameter passed to a formal parameter inside a method? It isn't! I ended up in interpreting the call stack and parsing the calling code!
I guess there is no simple solution. I expect that the compiler interprets the symbolic names ZCL_SUPER=> and ZCL_SUB=> in order to point to the method and forgets about it. Why should it keep the information? In fact I have a similar problem: Is there a simple way to find out the name of an actual parameter passed to a formal parameter inside a method? It isn't! I ended up in interpreting the call stack and parsing the calling code!
2016 Mar 23 8:15 AM
Thanks Horst,
I was looking on CL_DEMO_OUTPUT before, but I thought that maybe there is other way Now I need some time to adapt this to my need.
Cheers
Łukasz
2016 Mar 23 8:35 AM
Moderator message: in future, please don't add your question to a question that's more than a few months old. Rather create a new question and link to the old.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |