OOPS ABAP: Me Keyword
Me Keyword:
To access the class attributes if variables are defined with the same name in method and class.
Example :
*&---------------------------------------------------------------------*
*& Report ZVB_ME
*&---------------------------------------------------------------------*
REPORT ZVB_ME.
CLASS class1 DEFINITION.
PUBLIC SECTION.
DATA:lv_a TYPE i VALUE '10'.
METHODS DISPLAY.
ENDCLASS.
CLASS CLASS1 IMPLEMENTATION.
METHOD DISPLAY.
DATA:LV_a TYPE I VALUE '20'.
WRITE: / lv_a.
WRITE: / me->lv_a. "calling class attribute using 'me' keyword
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA:LO_OBJ TYPE REF TO CLASS1.
CREATE OBJECT LO_OBJ.
LO_OBJ->DISPLAY( ).
output : 20
10
Comments
Post a Comment