<?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: Restricting Multiple Instances in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910096#M937571</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Through SE24 T-code we can handle the access specifiers(Public,Private,Protected) of a class.&lt;/P&gt;&lt;P&gt;While creating a class with SE24,the second screen's Instantiation field contains - 'Public,Private'..here we can declare Private to make the class private.This is the  best way to handle the visibility of a class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And  among the checkboxes 'Final &amp;amp; Only Modeled' ,only Final must be checked for this class to have no more instances.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do reward me if you find helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2008 13:11:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-10T13:11:07Z</dc:date>
    <item>
      <title>Restricting Multiple Instances</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910093#M937568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How to create a Private Class &amp;amp; Restrict Multiple Instantiations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;Ravi S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 07:04:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910093#M937568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T07:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Restricting Multiple Instances</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910094#M937569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ravi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you are talking about the &lt;STRONG&gt;SINGLETON&lt;/STRONG&gt; pattern.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define the instantiation of your class as &lt;EM&gt;private&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;Define a static private attribute MO_INSTANCE of TYPE REF TO &amp;lt;name of your class&amp;gt;.&lt;/P&gt;&lt;P&gt;To instantiate you need a static method (e.g. CREATE) which return an instance of your class (e.g. RETURNING parameter RO_INSTANCE).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD create.

  IF ( mo_instance IS BOUND ).
    ro_instance = mo_instance.
  ELSE.
    CREATE OBJECT mo_instance. 
    ro_instance = mo_instance.    
  ENDIF.
    

ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 07:57:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910094#M937569</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-06-06T07:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Restricting Multiple Instances</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910095#M937570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in addition to Uwe's advice you should define the class with "PRIVATE" instantiation. This has the effect of making it impossible to instantiate the class from outside itself - so only Uwe's CREATE method can be used to instantiate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a good SAP Press publication that covers this. It is called "Design Patterns in Object-Oriented ABAP" by Igor Barbaric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Graham Robbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2008 00:29:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910095#M937570</guid>
      <dc:creator>GrahamRobbo</dc:creator>
      <dc:date>2008-06-07T00:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Restricting Multiple Instances</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910096#M937571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Through SE24 T-code we can handle the access specifiers(Public,Private,Protected) of a class.&lt;/P&gt;&lt;P&gt;While creating a class with SE24,the second screen's Instantiation field contains - 'Public,Private'..here we can declare Private to make the class private.This is the  best way to handle the visibility of a class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And  among the checkboxes 'Final &amp;amp; Only Modeled' ,only Final must be checked for this class to have no more instances.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do reward me if you find helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 13:11:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910096#M937571</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T13:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Restricting Multiple Instances</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910097#M937572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; And  among the checkboxes 'Final &amp;amp; Only Modeled' ,only Final must be checked for this class to have no more instances.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Do reward me if you find helpful.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not correct.  Final prevents subclassing.  It has no effect whatsoever on instantiation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 13:16:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/restricting-multiple-instances/m-p/3910097#M937572</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-06-10T13:16:43Z</dc:date>
    </item>
  </channel>
</rss>

