Google Search - Blog...........

ABAP - OOPS: Use Of ME Keyword In Method Programming.

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.
-------------------------------------------------------------------------------------------
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 me->i_num , " 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

No comments:

Post a Comment