<?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: Singleton design pattern in OO ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269470#M1987703</link>
    <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;manjunathm&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;* Singleton means Private instantiation and globally access.&lt;/P&gt;&lt;P&gt;* Singleton class object create with in the class only we cant create a object  outside the class but we can access the components of that singleton class.  &lt;/P&gt;&lt;P&gt;* Creating a class in such way so that we can create exactly one object is called as
singleton.&lt;/P&gt;&lt;P&gt;REPORT ZAK_SINGLETON.&lt;BR /&gt;&lt;BR /&gt;class ZCL_SINGLETON_LOGIN definition&lt;BR /&gt; final&lt;BR /&gt; create private .&lt;BR /&gt;&lt;BR /&gt;public section.&lt;BR /&gt;&lt;BR /&gt; class-methods LOGIN.&lt;BR /&gt;&lt;BR /&gt;private section.&lt;BR /&gt;&lt;BR /&gt; class-data LV_INST type ref to ZCL_SINGLETON_LOGIN .&lt;BR /&gt;&lt;BR /&gt; class-methods INSTANCE&lt;BR /&gt; returning&lt;BR /&gt; value(RO_INST) type ref to ZCL_SINGLETON_LOGIN .&lt;BR /&gt;&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;CLASS ZCL_SINGLETON_LOGIN IMPLEMENTATION.&lt;BR /&gt;&lt;BR /&gt;method INSTANCE.&lt;BR /&gt;&lt;BR /&gt; IF LV_INST IS NOT BOUND.&lt;BR /&gt; CREATE OBJECT RO_INST.&lt;BR /&gt; LV_INST = RO_INST.&lt;BR /&gt; ELSE.&lt;BR /&gt; RO_INST = LV_INST.&lt;BR /&gt; ENDIF.&lt;BR /&gt;endmethod.&lt;BR /&gt;&lt;BR /&gt;method LOGIN.&lt;BR /&gt; write : 'Demo For Singleton'.&lt;BR /&gt; endmethod.&lt;BR /&gt;&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;START-OF-SELECTION.&lt;BR /&gt;&lt;BR /&gt;ZCL_SINGLETON_LOGIN=&amp;gt;LOGIN( ).&lt;/P&gt;&lt;P&gt;Thankyou.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Nov 2020 03:32:07 GMT</pubDate>
    <dc:creator>former_member702682</dc:creator>
    <dc:date>2020-11-25T03:32:07Z</dc:date>
    <item>
      <title>Singleton design pattern in OO ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269467#M1987700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt; Please explain the Singleton design pattern with an example.&lt;/P&gt;
  &lt;P&gt;If you know any requirement you worked on please explain.&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Manjunath M&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 12:24:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269467#M1987700</guid>
      <dc:creator>former_member632800</dc:creator>
      <dc:date>2020-11-23T12:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton design pattern in OO ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269468#M1987701</link>
      <description>&lt;P&gt;Hello  &lt;SPAN class="mention-scrubbed"&gt;manjunathm&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://zevolving.com/2008/09/abap-object-design-patterns-singleton/" target="test_blank"&gt;http://zevolving.com/2008/09/abap-object-design-patterns-singleton/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;BR /&gt;Mateusz&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 12:26:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269468#M1987701</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2020-11-23T12:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton design pattern in OO ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269469#M1987702</link>
      <description>&lt;P&gt;Singleton pattern restricts multiple instantiation of a class by just letting create one instance.&lt;/P&gt;&lt;P&gt;The following is a short example of the singleton pattern.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report zsingleton.

class cl_singleton definition.
  public section.
    class-data p_my_class type ref to cl_singleton.
    class-methods get_instance returning value(r_my_class) type ref to cl_singleton.
endclass.

class cl_singleton implementation.
  method get_instance.
    if p_my_class is initial.
      write / 'Created new instance'.
      p_my_class = new #( ).
    else.
      write / 'Do not create new instance. Just return the same created before'.
    endif.
    r_my_class = p_my_class.
  endmethod.
endclass.

data lcl_my_class type ref to cl_singleton.

start-of-selection.

lcl_my_class = cl_singleton=&amp;gt;get_instance(  ). " -&amp;gt; Output: Created new instance
lcl_my_class = cl_singleton=&amp;gt;get_instance(  ). " -&amp;gt; Output: Do not create new instance. Just return the same created before
lcl_my_class = cl_singleton=&amp;gt;get_instance(  ). " -&amp;gt; Output: Do not create new instance. Just return the same created before

break-point.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For more information visit this link: &lt;A href="https://en.wikipedia.org/wiki/Singleton_pattern" target="test_blank"&gt;https://en.wikipedia.org/wiki/Singleton_pattern&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 15:17:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269469#M1987702</guid>
      <dc:creator>nmirandaghn</dc:creator>
      <dc:date>2020-11-23T15:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton design pattern in OO ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269470#M1987703</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;manjunathm&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;* Singleton means Private instantiation and globally access.&lt;/P&gt;&lt;P&gt;* Singleton class object create with in the class only we cant create a object  outside the class but we can access the components of that singleton class.  &lt;/P&gt;&lt;P&gt;* Creating a class in such way so that we can create exactly one object is called as
singleton.&lt;/P&gt;&lt;P&gt;REPORT ZAK_SINGLETON.&lt;BR /&gt;&lt;BR /&gt;class ZCL_SINGLETON_LOGIN definition&lt;BR /&gt; final&lt;BR /&gt; create private .&lt;BR /&gt;&lt;BR /&gt;public section.&lt;BR /&gt;&lt;BR /&gt; class-methods LOGIN.&lt;BR /&gt;&lt;BR /&gt;private section.&lt;BR /&gt;&lt;BR /&gt; class-data LV_INST type ref to ZCL_SINGLETON_LOGIN .&lt;BR /&gt;&lt;BR /&gt; class-methods INSTANCE&lt;BR /&gt; returning&lt;BR /&gt; value(RO_INST) type ref to ZCL_SINGLETON_LOGIN .&lt;BR /&gt;&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;CLASS ZCL_SINGLETON_LOGIN IMPLEMENTATION.&lt;BR /&gt;&lt;BR /&gt;method INSTANCE.&lt;BR /&gt;&lt;BR /&gt; IF LV_INST IS NOT BOUND.&lt;BR /&gt; CREATE OBJECT RO_INST.&lt;BR /&gt; LV_INST = RO_INST.&lt;BR /&gt; ELSE.&lt;BR /&gt; RO_INST = LV_INST.&lt;BR /&gt; ENDIF.&lt;BR /&gt;endmethod.&lt;BR /&gt;&lt;BR /&gt;method LOGIN.&lt;BR /&gt; write : 'Demo For Singleton'.&lt;BR /&gt; endmethod.&lt;BR /&gt;&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;START-OF-SELECTION.&lt;BR /&gt;&lt;BR /&gt;ZCL_SINGLETON_LOGIN=&amp;gt;LOGIN( ).&lt;/P&gt;&lt;P&gt;Thankyou.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 03:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269470#M1987703</guid>
      <dc:creator>former_member702682</dc:creator>
      <dc:date>2020-11-25T03:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton design pattern in OO ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269471#M1987704</link>
      <description>&lt;P&gt;WIth SingleTon, I think the most important is to show that, two separated report access the same instance :&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/12988109/how-do-we-use-singleton-in-oo-abap-can-someone-ple.html" target="test_blank"&gt;https://answers.sap.com/questions/12988109/how-do-we-use-singleton-in-oo-abap-can-someone-ple.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 14:54:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-design-pattern-in-oo-abap/m-p/12269471#M1987704</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-11-25T14:54:31Z</dc:date>
    </item>
  </channel>
</rss>

