<?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 Singleton in ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400525#M193637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1) I have created a class with its instantiation set to private.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Declared a static attribute 'instance' in the class with TYPE REF to same class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) In the class constructor checked if instance is initial if it is then created an object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if instance initial.&lt;/P&gt;&lt;P&gt;    creat'e object instance.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) Created a method get_instance which exports the 'instance' attribute of the class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose this is fine for implementing the Singleton class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Created a sample program where I call get_instance of this class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open two sessions of SE80 and execute this program in debug mode. I see that each program is executing the class constructor and instance is initial every time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If instance is initial in each execution (with two parllel executions) then what is the purpose of declaring it as static.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since its initial create object is executed every time in&lt;/P&gt;&lt;P&gt;each execution. Then the instance is not unique and its not singleton.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can somebody explain signleton in ABAP. Why is it different from JAVA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Jul 2006 11:06:33 GMT</pubDate>
    <dc:creator>seshatalpasai_madala</dc:creator>
    <dc:date>2006-07-10T11:06:33Z</dc:date>
    <item>
      <title>Singleton in ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400525#M193637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1) I have created a class with its instantiation set to private.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Declared a static attribute 'instance' in the class with TYPE REF to same class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) In the class constructor checked if instance is initial if it is then created an object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if instance initial.&lt;/P&gt;&lt;P&gt;    creat'e object instance.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4) Created a method get_instance which exports the 'instance' attribute of the class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose this is fine for implementing the Singleton class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Created a sample program where I call get_instance of this class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open two sessions of SE80 and execute this program in debug mode. I see that each program is executing the class constructor and instance is initial every time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If instance is initial in each execution (with two parllel executions) then what is the purpose of declaring it as static.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since its initial create object is executed every time in&lt;/P&gt;&lt;P&gt;each execution. Then the instance is not unique and its not singleton.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can somebody explain signleton in ABAP. Why is it different from JAVA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jul 2006 11:06:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400525#M193637</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2006-07-10T11:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton in ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400526#M193638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your class object exists per default once per session. As of release 6.40 you can create objects in the shared memory (with addition AREA HANDLE), thus session-independent! For that, you need to mark the class as shared-memory enabled. This should create a singleton as in Java.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Georg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2006 08:43:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400526#M193638</guid>
      <dc:creator>former_member256416</dc:creator>
      <dc:date>2006-07-12T08:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton in ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400527#M193639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Georg,&lt;/P&gt;&lt;P&gt;   I am aware of the Shared Objects concept. What I was not aware was Singleton implementation model of java do not work in ABAP. Any way thanks for the reply. I am awarding you some points for the reply :-).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2006 09:48:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-in-abap/m-p/1400527#M193639</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2006-07-12T09:48:20Z</dc:date>
    </item>
  </channel>
</rss>

