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 VALUE '10'.
  METHODS DISPLAY.
  ENDCLASS.
  CLASS CLASS1 IMPLEMENTATION.
    METHOD DISPLAY.
      DATA:LV_a TYPE 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

Popular posts from this blog

CDS Views: Table Functions with Example

Passing Dynamic Variables to SO10 TEXT

Adobe Form/PDF Form Introduction