<?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 Class is instantiating with out having GET_INSTANCE method! in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492465#M1746256</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;I saw a standard SAP class in PPM module, it doesn't have GET_INSTANCE method, but it has CLASS_CONSTRUCTOR and CONSTRUCTOR methods, and also it has GET_ATTRIBUTES method (actually, i want to call this method in my_z_prog), well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, i want to use GET_ATTRIBUTES method of this class in my_z_prog, but when i checked this class in SE24 i didn't find any GET_INSTANCE method, hence i thought i can't use this class bcz of no chance of instantiting of this class &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, one of another developer (now, rolled off and out of project) called the same mathod / class by using the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;DATA: lr_std_sap_class TYPE REF TO std_sap_class&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT lr_std_sap_class&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;iv_employee_number = lv_my_number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD lr_std_sap_class-&amp;gt;get_attributes&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;es_attributes = ls_my_attributes&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Pls. let me know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) With out having GET_INSTANCE method in it how its possible to create a OBJECT from out side (my_z_prog)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) What is the difference between GET_INSTANCE method and CONSTRUCOR method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) In this case how we are getting instance by using CREATE OBJECT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) The above is safe? i&amp;nbsp; mean, can go with the same approach?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i tested this class in SE24 i saw the INSTANCE push button on the tool bar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Jun 2013 00:54:51 GMT</pubDate>
    <dc:creator>former_member202077</dc:creator>
    <dc:date>2013-06-13T00:54:51Z</dc:date>
    <item>
      <title>Class is instantiating with out having GET_INSTANCE method!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492465#M1746256</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;I saw a standard SAP class in PPM module, it doesn't have GET_INSTANCE method, but it has CLASS_CONSTRUCTOR and CONSTRUCTOR methods, and also it has GET_ATTRIBUTES method (actually, i want to call this method in my_z_prog), well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, i want to use GET_ATTRIBUTES method of this class in my_z_prog, but when i checked this class in SE24 i didn't find any GET_INSTANCE method, hence i thought i can't use this class bcz of no chance of instantiting of this class &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, one of another developer (now, rolled off and out of project) called the same mathod / class by using the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;DATA: lr_std_sap_class TYPE REF TO std_sap_class&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT lr_std_sap_class&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;iv_employee_number = lv_my_number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD lr_std_sap_class-&amp;gt;get_attributes&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;es_attributes = ls_my_attributes&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Pls. let me know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) With out having GET_INSTANCE method in it how its possible to create a OBJECT from out side (my_z_prog)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) What is the difference between GET_INSTANCE method and CONSTRUCOR method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) In this case how we are getting instance by using CREATE OBJECT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) The above is safe? i&amp;nbsp; mean, can go with the same approach?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i tested this class in SE24 i saw the INSTANCE push button on the tool bar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 00:54:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492465#M1746256</guid>
      <dc:creator>former_member202077</dc:creator>
      <dc:date>2013-06-13T00:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Class is instantiating with out having GET_INSTANCE method!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492466#M1746257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://help.sap.com/abapdocu_70/en/ABAPCREATE_OBJECT.htm"&gt;CREATE OBJECT&lt;/A&gt; statement is used to create instance of a class, and using that object you can call instance methods, like get_attributes. During debug, you can see that when object is created, constructor method gets called.&lt;/P&gt;&lt;P&gt;On the other hand, get_instance is usually a static method, which creates object and return reference. When you check code inside get_instance, chances are that there would be CREATE OBJECT statement written inside it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 02:27:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492466#M1746257</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-13T02:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Class is instantiating with out having GET_INSTANCE method!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492467#M1746258</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;CREATE OBJECT does the instantiation. Go through the ABAP OO learning series done by &lt;A __default_attr="16476" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://community.sap.com/"&gt;&lt;/A&gt;. Its the best way to start off and know the basics of OO ABAP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="active_link" href="https://answers.sap.com/docs/DOC-10236" title="http://scn.sap.com/docs/DOC-10236"&gt;http://scn.sap.com/docs/DOC-10236&lt;/A&gt;&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>Thu, 13 Jun 2013 02:53:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492467#M1746258</guid>
      <dc:creator>arindam_m</dc:creator>
      <dc:date>2013-06-13T02:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Class is instantiating with out having GET_INSTANCE method!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492468#M1746259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any help pls.?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 03:45:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492468#M1746259</guid>
      <dc:creator>former_member202077</dc:creator>
      <dc:date>2013-06-13T03:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Class is instantiating with out having GET_INSTANCE method!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492469#M1746260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CREATE OBJECT is used to creates the instance of the class, which holds all the methods and attributes. It uses the Class's CONSTRUCTOR for creating the method. Whether you define the constructor or not, it will be present in the class whenever you create a class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET_INSTANCE is a user define method which returns the instance of the class. Usually this method is used only if the CONSTRUCTOR is private. This method comes into picture when we need SINGLETON CLASS (only one instance will be there through out the program).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The GET_INSTANCE method in turn uses the CREATE OBJECT to create an object if the object is not created previously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Working:&lt;/P&gt;&lt;P&gt;Assume there is class with name ZCL_TEST.&lt;/P&gt;&lt;P&gt;1. There will be a global reference variable in the class of type same as the current class.&lt;/P&gt;&lt;P&gt;g_ref_instance TYPE REF TO zcl_test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Make the constructor private, so that only through GET_INSTANCE method the objects can be created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create an method GET_INSTANCE which returns the reference of zcl_test.&lt;/P&gt;&lt;P&gt;METHOD get_instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF g_ref_instance IS NOT BOUND.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE OBJECT g_ref_instance TYPE zcl_test.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDIF.&lt;/P&gt;&lt;P&gt;rt_instance = g_ref_instance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rt_instance is an RETURNING parameters of this method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the above you can see, if g_ref_instance in not created then it creates else returns the previous instance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 05:02:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-is-instantiating-with-out-having-get-instance-method/m-p/9492469#M1746260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-13T05:02:45Z</dc:date>
    </item>
  </channel>
</rss>

