<?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 class - does this work for a User Session or for whole client ?? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384096#M1238025</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;As per my understanding the Singleton is supposed to have only &lt;STRONG&gt;one instance of class per user session&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, &lt;STRONG&gt;I am in doubt that whether Singleton is instantiated only once for multiple user sessions&lt;/STRONG&gt;. Can any one validate this idea and have a definite answer ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If singleton is instantiated only once per client (meaning multiple user sessions) will that be one singleton  class used for all sessions ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would greatly appreciate your help and comments..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: jakk on Mar 23, 2009 8:41 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Mar 2009 15:41:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-23T15:41:17Z</dc:date>
    <item>
      <title>Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384096#M1238025</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;As per my understanding the Singleton is supposed to have only &lt;STRONG&gt;one instance of class per user session&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, &lt;STRONG&gt;I am in doubt that whether Singleton is instantiated only once for multiple user sessions&lt;/STRONG&gt;. Can any one validate this idea and have a definite answer ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If singleton is instantiated only once per client (meaning multiple user sessions) will that be one singleton  class used for all sessions ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would greatly appreciate your help and comments..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: jakk on Mar 23, 2009 8:41 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 15:41:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384096#M1238025</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-23T15:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384097#M1238026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your understanding is correct: "one instance of class per user session".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would create a new object for each different user session.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this sample code. Put a breakpoint in the method GET_OBJECT. Run the report, stop at the breakpoint. Now, start a new Session and run the report again and you will see that it would create a new object for the new session.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*----------------------------------------------------------------------*
*       CLASS lcl_add DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_add DEFINITION CREATE PRIVATE.

  PUBLIC SECTION.
    CLASS-DATA: w_time TYPE sy-uzeit.

    CLASS-METHODS:
      get_object
        EXPORTING
          eo_add TYPE REF TO lcl_add.

  PRIVATE SECTION.
    CLASS-DATA: lo_add TYPE REF TO lcl_add.

ENDCLASS.                    "lcl_add DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_add IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_add IMPLEMENTATION.

  METHOD get_object.

    IF lcl_add=&amp;gt;lo_add IS INITIAL.

      CREATE OBJECT lcl_add=&amp;gt;lo_add.

      GET TIME FIELD w_time.

    ENDIF.

    eo_add = lcl_add=&amp;gt;lo_add.

  ENDMETHOD.                    "get_object

ENDCLASS.                    "lcl_add IMPLEMENTATION


START-OF-SELECTION.

  DATA: o_add TYPE REF TO lcl_add.

  DATA: l_test TYPE char10.

  l_test = 'TEST'.

  CALL METHOD lcl_add=&amp;gt;get_object
    IMPORTING
      eo_add = o_add.

  WRITE: / lcl_add=&amp;gt;w_time.

  CLEAR o_add.

  CALL METHOD lcl_add=&amp;gt;get_object
    IMPORTING
      eo_add = o_add.

  WRITE: / lcl_add=&amp;gt;w_time.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 15:48:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384097#M1238026</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-03-23T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384098#M1238027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code that you gave is for a &lt;STRONG&gt;local&lt;/STRONG&gt; singleton class. What would happen for Global Singleton class that is created from SE24 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: jakk on Mar 23, 2009 9:08 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 16:03:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384098#M1238027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-23T16:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384099#M1238028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That would remain same. Try with a global class same as this example local class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 16:47:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384099#M1238028</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-03-23T16:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384100#M1238029</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;  &lt;STRONG&gt;I am in doubt that whether Singleton is instantiated only once for multiple user sessions&lt;/STRONG&gt;. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;No, that is not the case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 18:11:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384100#M1238029</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2009-03-23T18:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384101#M1238030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Matt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking from conceptual point of view; that a Singleton (Global Class created in SE24) is instantiated only once for a user session. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Even though user is same (in case of RFC CALLS) each session (LUW) has separate Singleton intance.&lt;/STRONG&gt; I hope this is correct understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 18:42:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384101#M1238030</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-23T18:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Singleton class - does this work for a User Session or for whole client ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384102#M1238031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. It is correct "Even though user is same (in case of RFC CALLS) each session (LUW) has separate Singleton intance".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Singleton object's life time is based on the internal ABAP Session.&lt;/P&gt;&lt;P&gt;Like: &lt;/P&gt;&lt;P&gt;If you have a Singleton object for some business requirement in the Sales Order Processing, than the singleton would be active till you left the order processing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 20:09:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-class-does-this-work-for-a-user-session-or-for-whole-client/m-p/5384102#M1238031</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-03-23T20:09:26Z</dc:date>
    </item>
  </channel>
</rss>

