<?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: me and type ref in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/me-and-type-ref/m-p/1847290#M359282</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;I have added some comments to the coding which hopefully clarify your questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_OO_CLIENT_SERVER
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_oo_client_server.

*report self_reference.

CLASS client DEFINITION.
  PUBLIC SECTION.
    DATA name(10) TYPE c VALUE 'master' READ-ONLY.
    METHODS create_server.
ENDCLASS.                    "client DEFINITION

*---------------------------------------------------------------------*
*       CLASS server DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS server DEFINITION.
  PUBLIC SECTION.
    METHODS acknowledge
              IMPORTING
                creator TYPE REF TO client.                 "confused 1

  PRIVATE SECTION.
    DATA name(10) TYPE c VALUE 'servant'.
ENDCLASS.                    "server DEFINITION

*---------------------------------------------------------------------*
*       CLASS client IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS client IMPLEMENTATION.
  METHOD create_server.
    DATA server_ref TYPE REF TO server.

    CREATE OBJECT server_ref.
    CALL METHOD server_ref-&amp;gt;acknowledge
      EXPORTING
        creator = me.                                       "confused 2
*   NOTE: me == instance created with CREATE OBJECT client_ref.
*         We are now WITHIN this instance and, therefore, can refer
*   to it using ME (NOTE: in Java we use THIS).
  ENDMETHOD.                    "create_server
ENDCLASS.                    "client IMPLEMENTATION

*---------------------------------------------------------------------*
*       CLASS server IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS server IMPLEMENTATION.
  METHOD acknowledge.
    DATA name TYPE string.

*   NOTE: creator has been imported into this method. Creator is
*         the previously created instance of client. Because we are
*   now in the server class ME does refer to the server instance and
*   not the client instance.
    name = creator-&amp;gt;name.                                   "confused 3
*   NOTE: this is bad programming because the class has a private
*         instance attribute NAME and this method a local variable
*   of the same name.
*   The instance attribute me-&amp;gt;name has the predefined value
*   'servant' whereas the local variable now has the value 'master'
*   corresponding to the NAME attribute of the client class
*


*   NOTE: here ME represents the server instance because we are
*         within a server class method.
    WRITE: me-&amp;gt;name, 'created by', name.                    "confused 4

  ENDMETHOD.                    "acknowledge
ENDCLASS.                    "server IMPLEMENTATION

DATA client_ref TYPE REF TO client.

START-OF-SELECTION.

* NOTE: every class has a CONSTRUCTOR method, either explicitly
*       defined or it is IMPLICITLY called (like in this case).
  CREATE OBJECT client_ref.

  WRITE: / client_ref-&amp;gt;name.  " public attribute -&amp;gt; accessible here
  SKIP.


  CALL METHOD client_ref-&amp;gt;create_server.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&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>Sun, 04 Feb 2007 20:08:05 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2007-02-04T20:08:05Z</dc:date>
    <item>
      <title>me and type ref</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/me-and-type-ref/m-p/1847289#M359281</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;i read the book written by dr horst keller and sascha kruger "abap objects" with confusion on the below script. really hope can get the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) confused 1, why creator has no create object and only create reference variable? why no need to create instance of client class?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) confused 2. why only me? me means everything(attribute/method) of client class? why not define as me-&amp;gt;name just like in confused 4?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) why creator no create object also can creator-&amp;gt;name? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report self_reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class client definition.&lt;/P&gt;&lt;P&gt;public section.&lt;/P&gt;&lt;P&gt;data name(10) type c value 'master' read-only.&lt;/P&gt;&lt;P&gt;methods create_server.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class server definition.&lt;/P&gt;&lt;P&gt;public section.&lt;/P&gt;&lt;P&gt;methods acknowledge importing creator type ref to client. "confused 1&lt;/P&gt;&lt;P&gt;private section.&lt;/P&gt;&lt;P&gt;data name(10) type c value 'servant'.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class client implementation.&lt;/P&gt;&lt;P&gt;method create_server.&lt;/P&gt;&lt;P&gt;data server_ref type ref to server.&lt;/P&gt;&lt;P&gt;create object server_ref.&lt;/P&gt;&lt;P&gt;call method server_ref-&amp;gt;acknowledge exporting creator = me. "confused 2&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class server implementation.&lt;/P&gt;&lt;P&gt;method acknowledge.&lt;/P&gt;&lt;P&gt;data name type string.&lt;/P&gt;&lt;P&gt;name = creator-&amp;gt;name. "confused 3&lt;/P&gt;&lt;P&gt;write: me-&amp;gt;name, 'created by', name. "confused 4&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data client_ref type ref to client.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;create object client_ref.&lt;/P&gt;&lt;P&gt;call method client_ref-&amp;gt;create_server&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the output is "servant created by master".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Feb 2007 11:14:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/me-and-type-ref/m-p/1847289#M359281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-03T11:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: me and type ref</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/me-and-type-ref/m-p/1847290#M359282</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;I have added some comments to the coding which hopefully clarify your questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_OO_CLIENT_SERVER
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_oo_client_server.

*report self_reference.

CLASS client DEFINITION.
  PUBLIC SECTION.
    DATA name(10) TYPE c VALUE 'master' READ-ONLY.
    METHODS create_server.
ENDCLASS.                    "client DEFINITION

*---------------------------------------------------------------------*
*       CLASS server DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS server DEFINITION.
  PUBLIC SECTION.
    METHODS acknowledge
              IMPORTING
                creator TYPE REF TO client.                 "confused 1

  PRIVATE SECTION.
    DATA name(10) TYPE c VALUE 'servant'.
ENDCLASS.                    "server DEFINITION

*---------------------------------------------------------------------*
*       CLASS client IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS client IMPLEMENTATION.
  METHOD create_server.
    DATA server_ref TYPE REF TO server.

    CREATE OBJECT server_ref.
    CALL METHOD server_ref-&amp;gt;acknowledge
      EXPORTING
        creator = me.                                       "confused 2
*   NOTE: me == instance created with CREATE OBJECT client_ref.
*         We are now WITHIN this instance and, therefore, can refer
*   to it using ME (NOTE: in Java we use THIS).
  ENDMETHOD.                    "create_server
ENDCLASS.                    "client IMPLEMENTATION

*---------------------------------------------------------------------*
*       CLASS server IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS server IMPLEMENTATION.
  METHOD acknowledge.
    DATA name TYPE string.

*   NOTE: creator has been imported into this method. Creator is
*         the previously created instance of client. Because we are
*   now in the server class ME does refer to the server instance and
*   not the client instance.
    name = creator-&amp;gt;name.                                   "confused 3
*   NOTE: this is bad programming because the class has a private
*         instance attribute NAME and this method a local variable
*   of the same name.
*   The instance attribute me-&amp;gt;name has the predefined value
*   'servant' whereas the local variable now has the value 'master'
*   corresponding to the NAME attribute of the client class
*


*   NOTE: here ME represents the server instance because we are
*         within a server class method.
    WRITE: me-&amp;gt;name, 'created by', name.                    "confused 4

  ENDMETHOD.                    "acknowledge
ENDCLASS.                    "server IMPLEMENTATION

DATA client_ref TYPE REF TO client.

START-OF-SELECTION.

* NOTE: every class has a CONSTRUCTOR method, either explicitly
*       defined or it is IMPLICITLY called (like in this case).
  CREATE OBJECT client_ref.

  WRITE: / client_ref-&amp;gt;name.  " public attribute -&amp;gt; accessible here
  SKIP.


  CALL METHOD client_ref-&amp;gt;create_server.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&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>Sun, 04 Feb 2007 20:08:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/me-and-type-ref/m-p/1847290#M359282</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-02-04T20:08:05Z</dc:date>
    </item>
  </channel>
</rss>

