<?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/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>
    <dc:creator>Tomas_Buryanek</dc:creator>
    <dc:date>2015-04-16T11:58:08Z</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>

