Skip to Content
avatar image
Former Member

Use of 'ME' keyword in ABAP Objects?

Hi all,

Can any one please use of 'ME' keyword in ABAP Objects?

Thanks,

Vijay.

Moderator message: next time, please search for available information before asking.

Edited by: Thomas Zloch on Sep 16, 2010 5:33 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 14, 2010 at 06:25 AM

    Hi,

    Please find the description about the ME keyword as per the SAP documentation and help.sap.com.

    Within the implementation of every instance method, an implicitly created local reference variable called me is available, which points to the instance in which the method is currently being executed. The static type of me is the class in which the instance method is implemented.

    Each class implicitly contains the reference variable me. In objects, the reference variable mealways contains a reference to the respective object itself and is therefore also referred to as the self-reference. Within a class, you can use the self-reference me to access the individual class components:

    -To access an attribute attr of your class: me->attr

    -To call a method meth of your class: CALL METHOD me->meth

    When you work with attributes of your own class in methods, you do not need to specify a reference variable. The self-reference me is implicitly set by the system. Self-references allow an object to give other objects a reference to it. You can also access attributes in methods from within an object even if they are obscured by local attributes of the method.

    Regards,

    Sagar

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 14, 2010 at 06:21 AM

    Me - Current implementation of Object.

    Regards

    Vinod

    Add comment
    10|10000 characters needed characters exceeded

    • HI,

         Suppose you have two variables of same name,one in the definition part of class and another one    in  the implementation part of the class( in method). ME keyword is used to access variable of class .

      class sai definition.

      public section.

      data:num type i value 5.

      methods:meth.

      endcalss.

      class sai implementation.

      method meth.

      data: num type i value 10.

      write:/5 me->num . "Access variable of class

             /5 num.          " Access variable of method.

      endmethod.

      endclass.

      start-of-selection.

      data obj type ref to sai.

      create object obj.

      call method obj->meth.

      Moderator Message - Please do not post replies to dead threads & push them up the updates queue.

      Message was edited by: Suhas Saha

  • avatar image
    Former Member
    Apr 14, 2010 at 06:26 AM

    Hi Vijay,

    Within the implementation of every instance method, an implicitly created local reference variable called me is available, which points to the instance in which the method is currently being executed. me is treated like a local constant, which means the value of me cannot be altered in an instance method. The static type of me is the class in which the instance method is implemented.

    for more information refer,

    [http://help.sap.com/abapdocu_70/en/ABENSPACE_ME_SCREEN.htm]

    Regards,

    Raghava.Channooru.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2010 at 02:48 PM

    Hello Vinod,

    The primary usage of the keyword/reference 'ME' is for differentiating between Global and Local parameters declared in the classes. If a variable is declared within the Public section of the class(Eg: Data: GV_var1(10) type C) and if the same variable declared within another Method(Data: GV_var1(10) type C) declared in the Public section, there would be a conflict in accessing these same name data variables, because they've been declare as Global and Local.

    To avoid the conflict, to access/pass values to the the Global variable in any methods declared in the public section, use ME->GV_Var1 = 'NAME' and for local variable, use the standard way of passing value GV_Var1 = 'NAME' .

    Hope this will answer your query.

    Best Regards,

    Gopakumar

    Edited by: GOPAKUMAR LALITHAMBIKA on Sep 16, 2010 10:50 AM

    Edited by: GOPAKUMAR LALITHAMBIKA on Sep 16, 2010 10:52 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 17, 2010 at 07:12 AM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded