<?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 classes ?? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022288#M714497</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marcelo , the explanation and the examples were perfect !!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2007 05:09:11 GMT</pubDate>
    <dc:creator>abhishek_gupta2</dc:creator>
    <dc:date>2007-10-31T05:09:11Z</dc:date>
    <item>
      <title>singleton classes ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022285#M714494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I came across the statement in the code which i am reviewing .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;its :    &lt;/P&gt;&lt;P&gt;  CALL METHOD me-&amp;gt;get_id&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      internal = internal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can any one explain me here the use of ' &amp;lt;b&amp;gt;me-&amp;gt;get_id'&amp;lt;/b&amp;gt;. ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can i replace above statement by the following given code : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : cl_lcl type ref  to cl_click .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create object cl_lcl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD cl_lcl-&amp;gt;get_id&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      internal = internal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not , why ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks , &lt;/P&gt;&lt;P&gt;Abhishek .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 10:58:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022285#M714494</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T10:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: singleton classes ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022286#M714495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement is Often used to differentiate from a subclass attributes / methods to superclass attributes / methods or just differentiate from a global data of the class to a local data to a class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SAP Documentation Reference&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;During object creation, me also points to the instance of the generated subclass during the execution of an instance constructor of a superclass that has been called using super-&amp;gt;constructor. In the instance constructor of the superclass, or in methods that have been called by the instance constructor, specifying me-&amp;gt; with the method call has no effect. Instead, the method implementations of the superclass are always called. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you'll understand if look at the follow example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zself_reference.

*----------------------------------------------------------------------*
*       CLASS test DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS one DEFINITION.

  PUBLIC SECTION.

    METHODS get_id EXPORTING global_internal TYPE char01
                             local_internal  TYPE char01.

    METHODS test.

    DATA v_internal TYPE char01.

ENDCLASS.                    "one DEFINITION


*----------------------------------------------------------------------*
*       CLASS one IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS one IMPLEMENTATION.

  METHOD get_id.

    DATA v_internal TYPE char01.

*   Using ME you can diferentiate from Global, Local and Parameter

*   If you need to access Global v_internal definited on Public Section
*   you must use ME as identifier to actual instance os class test,
*   it's becouse there two DATA with the same name 'v_internal",
*   Otherwise you don't need to use ME !

*   Accessing Global DATA v_internal
    me-&amp;gt;v_internal = 'A'.
    MOVE me-&amp;gt;v_internal TO global_internal.

*   If you need to access Local v_internal definited in the method
*   you can't use ME !

*   Accessing Global DATA v_internal
    v_internal = 'B'.
    MOVE v_internal TO local_internal.

  ENDMETHOD.                    "get_id

  METHOD test.

    DATA v_global_internal TYPE char01.
    DATA v_local_internal  TYPE char01.

*   This statement call the method of own class ONE
    CALL METHOD get_id
      IMPORTING
        global_internal = v_global_internal
        local_internal  = v_local_internal.

    WRITE: / 'global_internal of Class One =&amp;gt; ', v_global_internal.
    WRITE: / 'local_internal of Class One =&amp;gt; ',  v_local_internal.

  ENDMETHOD.                    "test

ENDCLASS.                    "one IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS two DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS two DEFINITION INHERITING FROM one.

  PUBLIC SECTION.

    METHODS get_id REDEFINITION.
    METHODS test REDEFINITION.

ENDCLASS.                    "two DEFINITION

*----------------------------------------------------------------------*
*       CLASS two IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS two IMPLEMENTATION.

  METHOD get_id.

    DATA v_global_internal TYPE char01.
    DATA v_local_internal  TYPE char01.

*   Using the super-reference 'SUPER' you can diferentiate from Global, Local
*   and Parameter from Super class and Sub class Class

*   This statement call the method of super class ONE
    CALL METHOD super-&amp;gt;get_id
      IMPORTING
        global_internal = v_global_internal
        local_internal  = v_local_internal.

    WRITE: / 'global_internal of Super Class One in Class Two =&amp;gt; ', v_global_internal.
    WRITE: / 'local_internal of Super Class One in Class Two =&amp;gt; ',  v_local_internal.

    DATA v_internal TYPE char01.

*   Using the self-reference 'ME' you can diferentiate from Global, Local and Parameter

*   If you need to access Global v_internal definited on Public Section
*   you must use ME as identifier to actual instance os class test,
*   it's becouse there two DATA with the same name 'v_internal",
*   Otherwise you don't need to use ME !

*   Accessing Global DATA v_internal
    me-&amp;gt;v_internal = 'C'.
    MOVE me-&amp;gt;v_internal TO global_internal.

*   If you need to access Local v_internal definited in the method
*   you can't use ME !

*   Accessing Global DATA v_internal
    v_internal = 'D'.
    MOVE v_internal TO local_internal.

  ENDMETHOD.                    "get_id

  METHOD test.

    DATA v_global_internal TYPE char01.
    DATA v_local_internal  TYPE char01.

*   This statement call the method of own class ONE
    CALL METHOD get_id
      IMPORTING
        global_internal = v_global_internal
        local_internal  = v_local_internal.

    WRITE: / 'global_internal of Class Two Without ME =&amp;gt; ', v_global_internal.
    WRITE: / 'local_internal of Class Two Without ME =&amp;gt; ',  v_local_internal.

*   The same Behavior we have with the self-reference
    CALL METHOD me-&amp;gt;get_id
      IMPORTING
        global_internal = v_global_internal
        local_internal  = v_local_internal.

    WRITE: / 'global_internal of Class Two With ME =&amp;gt; ', v_global_internal.
    WRITE: / 'local_internal of Class Two With ME =&amp;gt; ',  v_local_internal.

  ENDMETHOD.                    "test

ENDCLASS.                    "two IMPLEMENTATION

DATA o_two TYPE REF TO two.

DATA v_global_internal TYPE char01.
DATA v_local_internal  TYPE char01.

START-OF-SELECTION.

  CREATE OBJECT o_two.

  CALL METHOD o_two-&amp;gt;test( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcelo Ramos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 13:21:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022286#M714495</guid>
      <dc:creator>marcelo_ramos1</dc:creator>
      <dc:date>2007-10-30T13:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: singleton classes ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022287#M714496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;me-&amp;gt;&amp;lt;/b&amp;gt; is to refer the class. A class can refer itself using the &amp;lt;b&amp;gt;me-&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot replace the ME-&amp;gt; reference with the object name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an example which would clarifies your doubt.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  Y_TEMP_OOABAP.

CLASS C1 DEFINITION.
  PUBLIC SECTION.
    DATA: NUM1 TYPE I VALUE 5.
  METHODS: TESTMETHOD.
ENDCLASS.

CLASS C1 IMPLEMENTATION.
  METHOD TESTMETHOD.
    DATA: NUM1 TYPE I VALUE 10.
    WRITE:/ ME-&amp;gt;NUM1,  " Accessing the variable which belongs to a class
            NUM1.      " Accessing local variable
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

  DATA: OREF TYPE REF TO C1.

  CREATE OBJECT OREF.

  OREF-&amp;gt;TESTMETHOD( ).

  WRITE:/ OREF-&amp;gt;NUM1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sreekanth&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;Reward if it helps you... ;)&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 14:24:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022287#M714496</guid>
      <dc:creator>sreekanthgo</dc:creator>
      <dc:date>2007-10-30T14:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: singleton classes ??</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022288#M714497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marcelo , the explanation and the examples were perfect !!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2007 05:09:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-classes/m-p/3022288#M714497</guid>
      <dc:creator>abhishek_gupta2</dc:creator>
      <dc:date>2007-10-31T05:09:11Z</dc:date>
    </item>
  </channel>
</rss>

