<?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: Static Method and Instance Method which to Prefer over another , when to use. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698410#M1768826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Maju ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for Explanation .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My 1st and 2nd doubt is somewhat clearer to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah its an EVENT Handler method .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And regarding the 3rd point&amp;nbsp; , with respect to link pointed by Manu , is&amp;nbsp; Polymorphism the only point were we prefer a Instance Method over Static ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Must say that document is really worthy one and it should be there in SCN as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Sep 2013 07:02:49 GMT</pubDate>
    <dc:creator>Sijin_Chandran</dc:creator>
    <dc:date>2013-09-09T07:02:49Z</dc:date>
    <item>
      <title>Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698405#M1768821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I encountered a Static Method implementation in one of the already developed objects in my Organization .&lt;/P&gt;&lt;P&gt;I have worked upon Instance Methods only like SET_TABLE_FOR_FIRST_DISPLAY of Class CL_GUI_ALV_GRID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Static Method is implemented in&amp;nbsp; a ZCLASS .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For calling an Instance method we have to do 3 steps i.e &lt;/P&gt;&lt;P&gt;a) Declare Reference Variable&lt;/P&gt;&lt;P&gt;b) Create Object using Constructor &lt;/P&gt;&lt;P&gt;c) Call Method(s) of the Object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And for Static Method we can call it directly &lt;/P&gt;&lt;P&gt;ZCLASS=&amp;gt;Method. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now in my scenario ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Method is called inside a BADI Implementation as shown below :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/276025" width="450" /&gt;&lt;/P&gt;&lt;P&gt;ZCOMMIT_BDC_QA11 is maintained in SE24 and Method BDC_MB1C is of Static type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now here is my doubts :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Why the programmer has called this method using SET HANDLER , ( any possible reasons )? &lt;/P&gt;&lt;P&gt;2. Is it possible to call the above method by simply writing ZCOMMIT_BDC_QA11=&amp;gt;BDC_MB1C .&lt;/P&gt;&lt;P&gt;3. &lt;STRONG&gt;When we prefer Static Method over Instance Method and Vice Versa&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have searched a lot and was not able to clarify these doubts of mine . It would be a great help if instead of Links a clear Explanation is made.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 06:25:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698405#M1768821</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2013-09-09T06:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698406#M1768822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sijin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please read the link, you will have a better idea, if you go through this link;&lt;/P&gt;&lt;P&gt;&lt;A href="http://zevolving.com/2013/03/abap-static-vs-instance-method-which-to-use-when/"&gt;&lt;/A&gt;&lt;A class="active_link" href="http://zevolving.com/2013/03/abap-static-vs-instance-method-which-to-use-when/"&gt;http://zevolving.com/2013/03/abap-static-vs-instance-method-which-to-use-when/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1735/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 06:34:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698406#M1768822</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-09T06:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698407#M1768823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For your 1st question, The &lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;BDC_MB1C&lt;/SPAN&gt; must be an event handler method. check in your class. please read more on Events and Methods.&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin: 3pt 0;"&gt;&lt;SPAN lang="DE" style="background-color: inherit !important; color: inherit !important; font-style: inherit !important;"&gt;To allow an event handler method to react to an event, you must determine at runtime the trigger to which it is to react. You need the following statement:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin: 3pt 0;"&gt;&lt;SPAN style="color: inherit !important; font-style: inherit !important; background-color: inherit !important; font-family: 'Courier New'; font-weight: bold;"&gt;SET HANDLER&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin: 3pt 0;"&gt;&lt;SPAN style="color: inherit !important; font-style: inherit !important; background-color: inherit !important; font-family: 'Courier New'; font-weight: bold;"&gt;more info for set handler: &lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2. After reading the documentation, hopefully u will understand difference between methods and Events.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. The link provide by Manu will give u the more about static and instance methods.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 06:44:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698407#M1768823</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-09T06:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698408#M1768824</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;I think the very basic way of differentiating would be when you want methods that you want to use like Utility Modules without depending on instance creation you can go for Static Methods. But when you want to use the methods only after the instance is created we do an Instance Method. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Static methods can be used as Utilities to achieve a common task across other codes that might not even need the various instance specific activities. The static methods usage can be seen in CL_ABAP_CHAR_UTILITIES. Here all methods have a fixed functionality and no instance specific task is required. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when ever you want a have methods behaviors. Instance Methods have the flexibility to be inherited and used in case additional functionality is required. You can check the ABAP OO presentation's by Thomas Jung.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Arindam&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 06:51:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698408#M1768824</guid>
      <dc:creator>arindam_m</dc:creator>
      <dc:date>2013-09-09T06:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698409#M1768825</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;Q1. Why the programmer has called this method using SET HANDLER , ( any possible reasons )?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still I need to know exact scenario.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q2. Is it possible to call the above method by simply writing ZCOMMIT_BDC_QA11=&amp;gt;BDC_MB1C?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call method and set handler are totally different but still possibly can be the same for certain scenarios.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q3. &lt;STRONG&gt;When we prefer Static Method over Instance Method and Vice-verse?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We prefer static method over instance when we don't need any details regarding an instance of a class(kinda generic one). We can use static method even before an instance is created for that class. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apart for these, there are few links&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://wiki.scn.sap.com/wiki/display/ABAP/Object+Oriented" title="http://wiki.scn.sap.com/wiki/display/ABAP/Object+Oriented"&gt;&lt;/A&gt;&lt;A href="http://wiki.scn.sap.com/wiki/display/ABAP/Object+Oriented" target="test_blank"&gt;http://wiki.scn.sap.com/wiki/display/ABAP/Object+Oriented&lt;/A&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://answers.sap.com/thread/793592" title="http://scn.sap.com/thread/793592"&gt;http://scn.sap.com/thread/793592&lt;/A&gt;&amp;nbsp; ----&amp;gt; This is more or less related to your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope these links will be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Dineshwar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:02:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698409#M1768825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-09T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698410#M1768826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Maju ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for Explanation .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My 1st and 2nd doubt is somewhat clearer to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah its an EVENT Handler method .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And regarding the 3rd point&amp;nbsp; , with respect to link pointed by Manu , is&amp;nbsp; Polymorphism the only point were we prefer a Instance Method over Static ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Must say that document is really worthy one and it should be there in SCN as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:02:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698410#M1768826</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2013-09-09T07:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698411#M1768827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply Arindam ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;I think the very basic way of differentiating would be when you want methods that you want to use like Utility Modules without depending on instance creation you can go for Static Methods. But when you want to use the methods only after the instance is created we do an Instance Method.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;Yeah this thing is very clear from the way they are used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;Static methods can be used as Utilities to achieve a common task across other codes that might not even need the various instance specific activities. The static methods usage can be seen in CL_ABAP_CHAR_UTILITIES. Here all methods have a fixed functionality and no instance specific task is required&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;So , POLYMORPHISM is the only feature which is lacked by Static Methods ? As the name Static is in its name as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:10:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698411#M1768827</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2013-09-09T07:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698412#M1768828</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;Some of the other restrictions are they can only access static attributes and trigger static events. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Arindam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:15:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698412#M1768828</guid>
      <dc:creator>arindam_m</dc:creator>
      <dc:date>2013-09-09T07:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698413#M1768829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Dineshwar ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That discussion was helpful one and the example of counter which was mentioned there is making the picture somewhat clearer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px; background-color: #ffffff;"&gt;only one copy of static methods be created for all static methods. They use the shared memory concept for all the static variables, methods or attributes&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;P&gt;Whereas for a Instance method always a fresh copy is created.&lt;/P&gt;&lt;P&gt;Need to workout on that example.&lt;/P&gt;&lt;P&gt;Very thanks for it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:18:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698413#M1768829</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2013-09-09T07:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Static Method and Instance Method which to Prefer over another , when to use.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698414#M1768830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;Q2. Is it possible to call the above method by simply writing ZCOMMIT_BDC_QA11=&amp;gt;BDC_MB1C?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;Call method and set handler are totally different &lt;STRONG&gt;but still possibly can be the same for certain scenarios&lt;/STRONG&gt;.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As I have mentioned that BDC_MB1C is EVENT METHOD , &lt;/P&gt;&lt;P&gt;So I think its not possible to use it without SET HANDLER irrespective of any scenarios , correct me if I am wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 07:29:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/static-method-and-instance-method-which-to-prefer-over-another-when-to-use/m-p/9698414#M1768830</guid>
      <dc:creator>Sijin_Chandran</dc:creator>
      <dc:date>2013-09-09T07:29:23Z</dc:date>
    </item>
  </channel>
</rss>

