<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Determine class name used for calling a static method in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979984#M1894964</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Hi Horst.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Quote from your post:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 12px; font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;"&gt;&lt;EM&gt;I don't see point (5) above as an exception to (4) but as a consequence because naming the class in the method call is not the same as addressing a component.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;





&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 12px; font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;SPAN style="color: #000000;"&gt;Just to check if we are using the same terms in the same sense: When in a language we refer to some data or code object (including class components), we are addressing some entity (the object) in a particular memory location. It's clear that the adressing occurs as a consequence of the reference, like when naming a static class component. In ABAP, &lt;SPAN style="font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;A href="http://help.sap.com/abapdocu_750/en/abenclass_ifac_components.htm"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN style="color: #008080;"&gt;the components of a class&lt;/SPAN&gt;&lt;SPAN style="color: #008080;"&gt;:&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/A&gt;a&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 12.8px; background-color: #fefeff; font-family: Arial;"&gt;ttributes and methods, are examples of those addressed objects.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12.8px; background-color: #fefeff; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px;"&gt;Looking clearly, the note (5) is not an exception of (4) but a contradiction. The note (5) says that if we refer to "&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;=&amp;gt;something()"&lt;/SPAN&gt;, where &lt;SPAN style="font-family: 'courier new', courier;"&gt;something&lt;/SPAN&gt; is a static component &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;inherited &lt;SPAN style="font-size: 12px;"&gt;from &lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier;"&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;(and not redefined) the compiler will interpret this as if we would be referring to the &lt;SPAN style="font-family: 'courier new', courier;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt;&lt;/STRONG&gt;=&amp;gt;something()"&lt;/SPAN&gt; &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;object, in the sense it will address that object.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px;"&gt;As we are talking about static components, that compiling simplification seems harmless... until we realize that as a consequence of this, compiler ends up calling &lt;EM&gt;only&lt;/EM&gt; the constructor of &lt;SPAN style="font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;/STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;super&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;and not the one of &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;. However, when we as developers, referred to &lt;SPAN style="font-family: 'courier new', courier;"&gt;"&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=&amp;gt;something()"&lt;/SPAN&gt;,&lt;/SPAN&gt; we didn't mean to refer to &lt;SPAN style="font-family: 'courier new', courier;"&gt;"&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=&amp;gt;something()"&lt;/SPAN&gt;,&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;right?&lt;/SPAN&gt; &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Is the compiler the one that makes that switch, and in a so strictly way that it doesn't call the expected static &lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;constructor&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; but only the &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; one&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="color: #000000;"&gt;Compare the above facts with the point (4), composed by the points (1) + (3), also in ABAP documentation. The point (1) says&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 12.8px; background-color: #fefeff;"&gt;The static constructor is called automatically ...&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;SPAN style="color: #800000;"&gt; before the class is first accessed. &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;SPAN style="color: #800000;"&gt;An access to the class is ... the addressing of a static component using the class component selector&lt;/SPAN&gt;". &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.8px; background-color: #fefeff; font-family: Arial;"&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif;"&gt;The tricky part here is: it is not possible to address a subclass &lt;SPAN style="font-size: 12.8px; background-color: #fefeff;"&gt;inherited component! &lt;/SPAN&gt;you can refer to it in your&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; code &lt;SPAN style="font-family: 'courier new', courier;"&gt;"&lt;SPAN style="color: #333333; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;=&amp;gt;something&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; but for the compiler considerations, you are addressing to&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new', courier;"&gt;"&lt;SPAN style="color: #333333; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=&amp;gt;something"&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="color: #000000;"&gt;This is a proposition of the form "&lt;EM&gt;P then Q&lt;/EM&gt;"&lt;/SPAN&gt; (&lt;SPAN style="color: #800000;"&gt;addressing &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;a static component &lt;SPAN style="color: #000000;"&gt;then&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;the static constructor is called automatically&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif;"&gt;) where &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;P can never be true (in our case of inherited static components), so the proposition in red is always true!! &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;SPAN style="color: #000000; font-family: arial, helvetica, sans-serif;"&gt;Nonetheless, the part (3) in (4) says &lt;SPAN style="color: #800000;"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 12.8px; background-color: #fefeff; font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="color: #800000;"&gt;When a subclass is first accessed... &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;&lt;SPAN style="color: #800000;"&gt; the static constructor of the superclass is executed followed by those of all subsequent subclasses up to the subclass in question..."&lt;/SPAN&gt;. Clearly &lt;SPAN style="color: #000000; font-family: Arial; font-size: 12.8px; background-color: #fefeff;"&gt;what happens contradict this. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;SPAN style="color: #000080; font-size: 12px;"&gt;Regarding a static constructor, there are no objects and its &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;task is to set the static attributes&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-size: 12px;"&gt; before they are needed the first time. And that is fullfilled in ABAP. Prove me wrong.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px;"&gt;Horst, of course that was proven wrong. In the example of Mike Pokraka, the call to the method &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;=&amp;gt;say_hello()&lt;/SPAN&gt; requires the previous setting of the &lt;SPAN style="font-family: 'courier new', courier;"&gt;hello&lt;/SPAN&gt; attribute with the value &lt;SPAN style="font-family: 'courier new', courier;"&gt;"World"&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; by the constructor&lt;/SPAN&gt;, &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;right&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt; whe&lt;/SPAN&gt;n the &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; class is referred for the very first time. However, for all we have seen above, the compiler, doesn't do that and executes only the &lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;super&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; constructor, completely disregarding the semantic meaning of the &lt;SPAN style="color: #000000; font-family: 'courier new', courier; font-size: 12px;"&gt;&lt;STRONG&gt;zcl_&lt;SPAN style="text-decoration: underline;"&gt;sub&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; static constructor. That's why the zcl_sub=&amp;gt;say_hello() unexpectedly writes "Hello".&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Or even better, follow thre &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.sap.com/abapdocu_750/en/index.htm?file=abenstatic_class_singleton_guidl.htm" style="font-size: 12px; color: #3778c7; background: #ffffff;"&gt;programming guideline&lt;/A&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt; &lt;/SPAN&gt;&lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1348/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Whaat??!! The Programming Guidelines are in public domain &lt;SPAN __jive_emoticon_name="shocked" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1348/images/emoticons/shocked.gif"&gt;&lt;/SPAN&gt;? I demand the refund for the book "Official ABAP ™ Programming Guidelines" I bought from SAP Press in 2013!! &lt;SPAN __jive_emoticon_name="laugh" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1348/images/emoticons/laugh.gif"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Now I understand why that guidelines recommend so adamantly to avoid the use of static classes (those with only static components). Conceptually I agree with that way of thinking, for all the good reasons exposed there. And now, even more because the issue we are dealing here.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;However, the described situation in ABAP affects not only &lt;SPAN style="color: #333333; font-size: 12px;"&gt;static classes, but also to those with just few static members. For example, I have a problem dealing with a hierarchy of exception classes whose constructors, as you know, are autogenerated by Netweaver and moreover can not be edited! This means, the only way to construct them without the regular constructors (this is for very good reasons, beyond the scope of this thread) is with static components. But this is minefield if I mix regular OOP factory designs with this peculiarity in ABAP.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;You should warn about this with red big size letters in the documentation, otherwise many will become crazy trying to chase a bug in their code, when it is &lt;EM&gt;a language feature&lt;/EM&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Interestingly, in the Scala language there are not static class components, they use i&lt;SPAN style="color: #333333; font-size: 12px;"&gt;nstead &lt;/SPAN&gt;"the &lt;EM&gt;companion object&lt;/EM&gt;", decoupling completely the static components from the really OOP ones. This way they can define any particular behavior for those &lt;EM&gt;companion objects&lt;/EM&gt; without clashing well known OOP behavior expected by the users as it is happening here.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Best regards.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;OdL&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Oct 2015 01:26:56 GMT</pubDate>
    <dc:creator>oscar_delama</dc:creator>
    <dc:date>2015-10-27T01:26:56Z</dc:date>
    <item>
      <title>Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979952#M1894932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, I have ZCL_SUPER with a static method HELLO and a subclass ZCL_SUB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can use ZCL_SUPER=&amp;gt;HELLO( ) or I can use ZCL_SUB=&amp;gt;HELLO( ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've found some similar threads but none with a clear answer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any input appreciated, &lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:38:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979952#M1894932</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-15T13:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979953#M1894933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no solution either, what if the caller is not an object?&lt;/P&gt;&lt;P&gt;You can always evaluate the ABAP call stack (function module SYSTEM_CALLSTACK).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JNN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 21:13:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979953#M1894933</guid>
      <dc:creator>nomssi</dc:creator>
      <dc:date>2015-04-15T21:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979954#M1894934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jacques,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the input. Call stack won't help because it never shows inheritance, always the implementing class of a method. You can see this in the debugger. I also doublechecked with system debugging on, same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only option there is to also go and parse the code of the calling program which adds more complexity than I'm trying to solve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesn't really matter whether the caller is an object or a report, I want to know whether the line of code that invoked my static method used ZCL_SUPER=&amp;gt; or ZCL_SUB=&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 10:10:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979954#M1894934</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-16T10:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979955#M1894935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a thought....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there was an ABAP equivalent to Java :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this.getClass().getName();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we can pass it as parameter .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 10:39:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979955#M1894935</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-04-16T10:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979956#M1894936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not think it is possible. At least not with ABAP Objects "logic".&lt;/P&gt;&lt;P&gt;There is no reference to caller object ("me" does not exist in static method).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe it is possible with some workaround. But for example SYSTEM_CALLSTACK would not help much with this problem, if you use local classes. I did not tried with global classes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 10:53:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979956#M1894936</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2015-04-16T10:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979957#M1894937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is equivalent reference "me" in ABAP and also cl_abap_classdescr. Problem is, that static method has no reference to "me".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 10:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979957#M1894937</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2015-04-16T10:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979958#M1894938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to use instance method, or add parameter ZCL=&amp;gt;HELLO( "id_of_call" )?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Or it has to be static method without parameters?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 11:02:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979958#M1894938</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2015-04-16T11:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979959#M1894939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see there GET_CLASS_NAME&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not test it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 11:04:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979959#M1894939</guid>
      <dc:creator>rosenberg_eitan</dc:creator>
      <dc:date>2015-04-16T11:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979960#M1894940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;cl_abap_classdescr=&amp;gt;get_class_name( me ) returns this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;\PROGRAM=ZTEST3\CLASS=ZCL_SUPER&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or better to use longer call, but shorter result &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1249/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt; :&lt;/P&gt;&lt;P&gt;lref = cl_abap_classdescr=&amp;gt;describe_by_object_ref( me ).&lt;/P&gt;&lt;P&gt;lref-&amp;gt;get_relative_name( ) which returns:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;ZCL_SUPER&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 11:58:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979960#M1894940</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2015-04-16T11:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979961#M1894941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's impossible to implement polymorphism using static methods in ABAP Objects.&amp;nbsp; So, there is no difference between &lt;SPAN style="color: #333333; font-size: 12px;"&gt;ZCL_SUPER=&amp;gt;HELLO( ) and ZCL_SUB=&amp;gt;HELLO( ) because you call exactly the same method in both cases&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 12:35:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979961#M1894941</guid>
      <dc:creator>former_member205488</dc:creator>
      <dc:date>2015-04-16T12:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979962#M1894942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, but no then I'm stuck with the original problem of making every call explicit, or I might as well create statics in each subclass which call the superclass with the appropriate information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both of which are exactly what I'm trying to avoid - the developer should be able to call my method in a subclass they create and not worry about the rest. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 15:37:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979962#M1894942</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-16T15:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979963#M1894943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Hi Mike,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Can I ask you why you want to know who called this method or by using what class name?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;You can also call the static method with an instance of the class. If you pass this instance to this method, you can use the object descriptor to know the type of the object. Generally if that is the object you are working on, you are more likely to use that object reference to call the static method.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="l0s311"&gt;*&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CLASS &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_super &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;DEFINITION&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;PUBLIC SECTION&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CLASS-METHODS&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;hello &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;IMPORTING &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;io_obj &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;TYPE REF TO &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_super&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;"lcl_super DEFINITION&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;*&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CLASS &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_sub &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;DEFINITION INHERITING FROM &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_super&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;"lcl_sub DEFINITION&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;START-OF-SELECTION&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;"lcl_sub=&amp;gt;hello( ).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;DATA&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_obj &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;TYPE REF TO &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_super&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CREATE &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;OBJECT lo_obj&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; lo_obj&lt;/SPAN&gt;&lt;SPAN class="l0s701"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;hello&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_obj &lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CREATE &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;OBJECT lo_obj &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_sub&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; lo_obj&lt;/SPAN&gt;&lt;SPAN class="l0s701"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;hello&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_obj &lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;BR /&gt; lcl_super&lt;/SPAN&gt;&lt;SPAN class="l0s701"&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;hello&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_obj &lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;*&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;CLASS &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lcl_super&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;IMPLEMENTATION&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;METHOD &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;hello&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;WRITE&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;/ &lt;/SPAN&gt;&lt;SPAN class="l0s331"&gt;'Im called'&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;DATA&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_objdesc &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;TYPE REF TO &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;cl_abap_objectdescr&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;DATA&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lv_name &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;string&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; lo_objdesc ?= cl_abap_objectdescr&lt;/SPAN&gt;&lt;SPAN class="l0s701"&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;describe_by_object_ref&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;io_obj &lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; lv_name &lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;= &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lo_objdesc&lt;/SPAN&gt;&lt;SPAN class="l0s701"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;get_relative_name&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;( ).&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;WRITE&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;:&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;lv_name&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;ENDMETHOD&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;"hello&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN class="l0s521"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="l0s551"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="l0s311"&gt;"lcl_super IMPLEMENTATION&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="l0s311"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="l0s311"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="l0s311"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="l0s311"&gt;Naimesh Patel&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 16:50:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979963#M1894943</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2015-04-16T16:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979964#M1894944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Naimesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the input. Background is that this method is part of an abstract superclass, and it should manage how/what subclasses may be instantiated. So at the time of the call no instance of any sort is known to the caller.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ideal 'OO way' would be a factory class returning an interface reference, but there's a long-winded reason for implementing the same idea in an inheritance tree with a static method at the top.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did tinker around with having the top level class as a singleton instance, not too dissimilar form your idea. But that added more complexity for the caller so no joy there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current best approach is to use a standalone factory class with a separate method for each subclass in my tree that takes the input and adds the class name to the call to the static method in question.&lt;/P&gt;&lt;P&gt;Anyone who creates a subclass would have to create a corresponding factory method. Clunky but workable:&lt;/P&gt;&lt;P&gt;ZCL_OBJ_FACTORY=&amp;gt;GET_SUB1( somedata )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;looks better than the really clunky:&lt;/P&gt;&lt;P&gt;ZCL_SUB1=&amp;gt;GET_INSTANCE( i_class = 'ZCL_SUB1'&amp;nbsp; i_somedata = somedata ).&lt;/P&gt;&lt;P&gt;(which is now hidden in each factory method...) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll leave this open for ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 21:27:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979964#M1894944</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-16T21:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979965#M1894945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike&lt;/P&gt;&lt;P&gt;This is exactly one of the reasons why our team no longer works with static methods. Use an instance method instead, even if the coding is not (yet) object specific. This enables you also to use the runtime descriptor for classes to determine the actual name [cl_abap_classdescr=&amp;gt;get_class_name( me )]&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Markus&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;class ZCL_SUPER &lt;SPAN class="L0S52"&gt;definition&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;public&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;create &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;public &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;public &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;methods &lt;/SPAN&gt;HELLO&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; returning&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;value&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;(&lt;/SPAN&gt;RV_NAME&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;type &lt;/SPAN&gt;STRING &lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;protected &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;private &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;CLASS &lt;/SPAN&gt;ZCL_SUPER &lt;SPAN class="L0S52"&gt;IMPLEMENTATION&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;METHOD &lt;/SPAN&gt;hello&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; rv_name &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;cl_abap_classdescr&lt;SPAN class="L0S70"&gt;=&amp;gt;&lt;/SPAN&gt;get_class_name&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;me &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;ENDMETHOD&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;class ZCL_SUB &lt;SPAN class="L0S52"&gt;definition&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;public&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;inheriting &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;from &lt;/SPAN&gt;ZCL_SUPER&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;create &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;public &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;public &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;protected &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;private &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;section&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;CLASS &lt;/SPAN&gt;ZCL_SUB &lt;SPAN class="L0S52"&gt;IMPLEMENTATION&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;ENDCLASS&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;Program:&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA&lt;SPAN class="L0S55"&gt;: &lt;/SPAN&gt;lo_obj &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;zcl_sub&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;DATA&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;: &lt;/SPAN&gt;lv_name &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;string&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;CREATE &lt;/SPAN&gt;OBJECT lo_obj&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;lv_name &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;lo_obj&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;hello&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;WRITE &lt;/SPAN&gt;lv_name&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2015 08:12:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979965#M1894945</guid>
      <dc:creator>markus_lanz3</dc:creator>
      <dc:date>2015-04-17T08:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979966#M1894946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Anyone who creates a subclass would have to create a corresponding factory method.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For FACTORY method, you should keep one method which gives the necessary object and hides the object creation complexity from the caller. Also, it should be out of your class hierarchy and into its own separate final class&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This makes sure, there is only single-responsibility of the class&lt;/LI&gt;&lt;LI&gt;No confusion of how static method is called, as the class is final and there will not be any subclass for this class&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;My current best approach is to use a standalone factory class with a separate method for each subclass in my tree that takes the input and adds the class name to the call to the static method in question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you should hide the class name from the caller - to decouple it. Instead, you should have a key which determines the class name. This key to class relationship could be defined &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Using certain naming standards - e.g. ZCL_DOSOMETHING_ZK01 where ZK01 is my key&lt;/LI&gt;&lt;LI&gt;Using hardcoding the key and class relation in the method FACTORY&lt;/LI&gt;&lt;LI&gt;Using a table where you have the key and class relation&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My preference is last option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this option of the factory, the caller can easily obtain different objects for different keys without worrying about which specific method to be called to get which specific object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2015 14:12:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979966#M1894946</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2015-04-17T14:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979967#M1894947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Naimesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Agree, as I explained, a standalone factory class is exactly what my current best-but-not-perfect approach is. Anyone who creates a subclass of main superclass also has to add a corresponding method to the factory class. The method name itself thus becomes the key, and inside it they need to pass the class name to the superclass. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I add a further key into the equation then I'm back to where I might as well require all implementers of the class hierarchy to pass their subclass name in: &lt;/P&gt;&lt;P&gt;ZCL_SUB7=&amp;gt;GET_INSTANCE( i_class = 'ZCL_SUB7' i_otherstuff = stuff ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't specifically want to hide the class name either. This is part of a larger framework where several developers will be creating subclasses, and these will be instantiated in various application scenarios. But in all cases the dev will know what they're trying to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is exactly the type of reason interfaces are preferable to inheritance, but in this case I'm stuck with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2015 19:03:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979967#M1894947</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-17T19:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979968#M1894948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Markus, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the input. Interesting idea of not using statics as a matter of policy.&lt;/P&gt;&lt;P&gt;I did play around with a couple of instance scenarios, but all those scenarios added even more complexity than the awkwardness I'm trying to eliminate. My problem (and the main reason for this setup) is to manage the instantiation - in some cases I will even get a different object back. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some scenarios: &lt;/P&gt;&lt;P&gt;- Developer may want to evaluate which subclass to use. &lt;/P&gt;&lt;P&gt;- Developer may not care about the exact type and get a subclass of what s/he is requesting (polymorphic instantiation). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So completely without statics I would end up with stuff like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA&lt;SPAN class="L0S55"&gt;: my&lt;/SPAN&gt;obj &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;zcl_sub&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;DATA&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;: value&lt;/SPAN&gt; &lt;SPAN class="L0S52"&gt;TYPE i&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;CREATE &lt;/SPAN&gt;OBJECT myobj type zcl_sub_low&lt;SPAN class="L0S55"&gt;. "pick the most likely sub-subtype to start with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;value &lt;SPAN class="L0S55"&gt;= my&lt;/SPAN&gt;obj&lt;SPAN class="L0S70"&gt;-&amp;gt;my_static_check&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;( somedata &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if value &amp;lt; zcl_super=&amp;gt;threshold. &lt;/P&gt;&lt;P&gt;&amp;nbsp; "Good, we got lucky&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;&amp;nbsp; "need different subclass&lt;/P&gt;&lt;P&gt;&amp;nbsp; clear myobj. &lt;/P&gt;&lt;P&gt;&amp;nbsp; create object myobj type zcl_sub_high. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;CREATE &lt;/SPAN&gt;OBJECT myobj type zcl_sub_low&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;classname = myobj-&amp;gt;get_appropriate_class( ). &lt;/P&gt;&lt;P&gt;if classname &amp;lt;&amp;gt; myobj-&amp;gt;get_classname( ).&lt;/P&gt;&lt;P&gt;&amp;nbsp; clear myobj.&lt;/P&gt;&lt;P&gt;&amp;nbsp; create myobj type (classname). &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is way too complex to do for every single instantiation of all the subclasses (there will be many!). So I'm trying to hide this type of logic in superclass statics and ideally have the developer just do: &lt;/P&gt;&lt;P&gt;if zcl_sub=&amp;gt;static_check( somedata ) &amp;lt;&amp;gt; abap_true. &lt;/P&gt;&lt;P&gt;&amp;nbsp; "decide on which class to use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or:&lt;/P&gt;&lt;P&gt;myobj ?= zcl_sub=&amp;gt;get_instance( somedata ). "could return various subclasses of zcl_sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both very simple to do with a static method of zcl_sub, but I would like to implement it in zcl_super. This would be so simple if a static would know as which class it is being called...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2015 19:59:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979968#M1894948</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-17T19:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979969#M1894949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this looks like &lt;EM&gt;Abstract Factory&lt;/EM&gt; to me, where you create a hierarchy of constructor classes in addition to your product hierarchy to have a stable object creation code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lo_factory = lcl_factories=&amp;gt;get_instance( somedata ).&amp;nbsp; " generates the appropriate factory object&lt;/P&gt;&lt;P&gt;lo_obj = lo_factory-&amp;gt;new( somedata ).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " generates the correct product&lt;/P&gt;&lt;P&gt;this could now be isolated in a static class if you use interfaces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The price to pay is to to subclass lcl_factories and update its get_instance( ) method each time you add a product subclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JNN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2015 00:20:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979969#M1894949</guid>
      <dc:creator>nomssi</dc:creator>
      <dc:date>2015-04-18T00:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979970#M1894950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jacques,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is indeed the best 'proper OO' solution to the scenario, although in my case I will end up with several factory classes.&lt;/P&gt;&lt;P&gt;In practice sadly it's too much work... I'm trying to create a framework which even junior developers &lt;EM&gt;want&lt;/EM&gt; to use - a 3-lines-of-code job, which would ave been possible if a static method new it's calling mechanism. &lt;/P&gt;&lt;P&gt;I like the abstract factory idea but I'm not going to sell this one to the masses who still think a class is a new-fangled replacement for a function group. &lt;SPAN __jive_emoticon_name="sad" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1273/images/emoticons/sad.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To all who replied: I have been pleasantly surprised and impressed by the overall level of good quality input on this thread, thanks to for much food for thought.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 21:03:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979970#M1894950</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2015-04-20T21:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Determine class name used for calling a static method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979971#M1894951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As fas as I know, static method cannot be redefined in a subclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if super class is an abstract class, then that means that static method also is an abstract method. This implies that super class should not call this method at all as there is no implementation of this method inside super class. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in a nutshell, if it is a usual super class, as the static methods cannot be redefined, so static method will always be called from super class only. &lt;/P&gt;&lt;P&gt;If it is an abstract super class, then as you cannot redefine the static method inside sub class, so what is the use of having it in super class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Richa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 04:31:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/determine-class-name-used-for-calling-a-static-method/m-p/10979971#M1894951</guid>
      <dc:creator>Richa_Gupta</dc:creator>
      <dc:date>2015-04-27T04:31:46Z</dc:date>
    </item>
  </channel>
</rss>

