Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reference varaible ME

Former Member
0 Likes
675

Hi all

can anybody please explain me about Reference varaible me in abap objects.

Thanks and Regards

vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
653

Hi,

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

During object creation, <b>me</b> also points to the instance of the generated subclass during the execution of an instance constructor of a superclass that has been called using <b>super->constructor</b>. In the instance constructor of the superclass, or in methods that have been called by the instance constructor, specifying <b>me-></b> with the method call has no effect. Instead, the method implementations of the superclass are always called.

Thanks & Regards

Santhosh

Hi all

can anybody please explain me about Reference varaible me in abap objects.

Thanks and Regards

vijay

4 REPLIES 4
Read only

h_senden2
Active Contributor
0 Likes
653

Within the class reference variable ME references to the current instance.

regards,

Hans

Please reward all helpful answers !!!!!

Read only

Former Member
0 Likes
654

Hi,

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

During object creation, <b>me</b> also points to the instance of the generated subclass during the execution of an instance constructor of a superclass that has been called using <b>super->constructor</b>. In the instance constructor of the superclass, or in methods that have been called by the instance constructor, specifying <b>me-></b> with the method call has no effect. Instead, the method implementations of the superclass are always called.

Thanks & Regards

Santhosh

Read only

sonu_p2
Active Participant
0 Likes
653

Hello vijaya,

Check out the code below......This will definitely help you to knw the concept of ME

1.1 Use of ME in methods

Theme A method can have a variable defined within it having the same name as one of the attributes of the class to which the method belongs to.

To clearly identify the class level attribute, the selector ME is used.

Program Description Class TESTCLASS contains method TESTMETHOD. There is a variable I_NUM declared as public attribute in the class as well as in the implementation part of the method.

To access the variable I_NUM at the class level within the method, the selector ME is used. Please see the ouputs of this program for better understanding.

Dump REPORT YSUBOOPS17 .

class testclass definition.

public section.

data : i_num type i value 5.

methods : testmethod .

endclass.

class testclass implementation.

method :testmethod.

data : i_num type i value 2.

write:/5<b> me->i_num</b> , " access variable of the class

/5 i_num . " access variable of the method

endmethod.

endclass.

start-of-selection.

data : i_num type i.

data : my_obj type ref to testclass.

create object : my_obj.

call method my_obj->testmethod.

Output 5 2

<b>Dont forget to reward points if it helps :-)</b>

Thanks,

Sachin

Read only

Former Member
0 Likes
653

Hi,

Within a class, you can use the self-reference ME to access the individual components:

To access an attribute <attr> in the same class: ME-><attr>

To call a method <meth> in the same class: CALL METHOD ME-><meth>

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,

Azaz Ali.