<?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: what is Singleton? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550891#M854340</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 29 Mar 2008 00:28:08 GMT</pubDate>
    <dc:creator>GrahamRobbo</dc:creator>
    <dc:date>2008-03-29T00:28:08Z</dc:date>
    <item>
      <title>what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550886#M854335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;What is Singleton? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Luke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 09:27:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550886#M854335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-28T09:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550887#M854336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check out the below code to understnad the same&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Singleton means having one instance and making sure that only that instance is used by all the programs or modules. This is generally acheived by making the class instatitation as Private and having an instance attribute in the class of its own type and having a method something like GET_INSTANCE which creates and returns the intance if the class if the instance is already not there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
program pattern_singleton.

***********************************************************************

    * Singleton
    * =========
    * Intent

*

    * Ensure a class has only one instance, and provide a global point
    * of access to it.

***********************************************************************

class lcl_Singleton definition create private.

public section.

class-methods:
get_Instance returning value(Result) type ref to lcl_Singleton.

private section.
class-data:
fg_Singleton type ref to lcl_Singleton.

endclass.


class lcl_Singleton implementation.

method get_Instance.
if ( fg_Singleton is initial ).
create object fg_Singleton.
endif.
Result = fg_Singleton.
endmethod.

endclass.
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 09:31:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550887#M854336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-28T09:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550888#M854337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Singleton property is mostly used to save memory &amp;amp; increase performance. we would go for singleton nodes in cases where UI needs only display from one-instance of data from my node.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;singleton property defines the number of instance of a perticular node.&lt;/P&gt;&lt;P&gt;suppose there is a node A and node A is having a sub node B, if node a is singleton selected means there exist only one instance of B for a.&lt;/P&gt;&lt;P&gt;Eg: if in node A we are populating flight details from Sflight and in node b we want to populate booking details for each flight in node A.&lt;/P&gt;&lt;P&gt;then if A is singletone selected means, for the selected record there will be corresponding details in B, ie if record ofFlight AA is selected in A, then booking details for flight AA is populated in Node B.&lt;/P&gt;&lt;P&gt;if node A is not singleton selected then, booking details for all the flights in Node A will be there in Node b at every instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;usually singlton proprty, we are using with supply function, we usually in the abouve example will give a supply fn to node b, so that based on the selection of a record in node a, supply function will populate corresponding record to node B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To understand this correctly....compare it with LOOP statement like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider the Loop statement having a control break statement AT NEW MATNR. Whenever the value of MATNR changes this statement is executed and some logic inside it is executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly, for the context node, when the value of the selected element in the node changes to something else i.e. the supply function method is triggered and code is executed in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider for example in case of Loop statement logic you want to get the material description.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For lead selection change of context node you want to update the material description on the view by making a select from the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Reward points if Useful&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Richa Khosla&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Richa Khosla on Mar 28, 2008 10:32 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Richa Khosla on Mar 28, 2008 10:34 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 09:31:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550888#M854337</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-28T09:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550889#M854338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try [this|http://en.wikipedia.org/wiki/Singleton_pattern] article in wikipedia.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Singletons are typically used when you ( the author of the class) want to ensure that there will only ever be a mamximum of one instance of the class.  As explained by one of the other respondents, instantiation is carried out through a method - it's important to realise this is of course a STATIC method - rather than through CREATE OBJECT.  In fact, you must make instantiation private, otherwise there's nothing to stop a user of your class using repeated CREATE OBJECTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'd use singleton for a database access object.  You've only one database, so you don't (usually) require more than one database access object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 11:44:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550889#M854338</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-03-28T11:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550890#M854339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Luke, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Singleton is a Design Pattern. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In &lt;EM&gt;Design Patterns: Elements of Reusable Object-Oriented Software&lt;/EM&gt; by Gamma, Helm, Johnson and Vlissides (also known as the "gang of four"), Addison-Wesley, 1995, it defines the Singleton's intent to &lt;EM&gt;"ensure that a class only has one instance, and provide a global point of access to it"&lt;/EM&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend the SAP Press publication &lt;EM&gt;Design Patterns in Object-Oriented ABA&lt;/EM&gt; by Igor Barbaric that covers this with code samples. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When coding in ABAP, you implement the Singleton design pattern by declaring a class as "PRIVATE". This means the class can only be instantiated from inside itself. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You then need a public static method to instantiate the class. When this method instantiates the class it stores a reference to the instance in a private or protected attribute. Before instantiating the class you check to see if the attribute is bound. If it is you skip instantiation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
METHOD instantiate_class. 
  IF zcl_myclass=&amp;gt;o_class IS NOT BOUND. 
    CREATE OBJECT zcl_myclass=&amp;gt;o_class. 
  ENDIF. 
ENDMETHOD. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &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, 29 Mar 2008 00:11:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550890#M854339</guid>
      <dc:creator>GrahamRobbo</dc:creator>
      <dc:date>2008-03-29T00:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550891#M854340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Mar 2008 00:28:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550891#M854340</guid>
      <dc:creator>GrahamRobbo</dc:creator>
      <dc:date>2008-03-29T00:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: what is Singleton?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550892#M854341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you to reply my question&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2008 05:39:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/what-is-singleton/m-p/3550892#M854341</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-14T05:39:48Z</dc:date>
    </item>
  </channel>
</rss>

