Tuesday, August 4, 2020

Calling a Protected method from a Public Method (class 4)

*&---------------------------------------------------------------------*
*& Report  ZOOABAP_CL4
*& Calling protected method from public method 
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zooabap_cl4.
CLASS lcl_emp DEFINITION .
  PUBLIC SECTION.
    METHODS set.
  PROTECTED SECTION.
    DATA empno   TYPE char10,
           empname TYPE char40,
           design  TYPE char10.
    METHODS display .

ENDCLASS.

CLASS lcl_emp IMPLEMENTATION.

  METHOD display.
    WRITE / empno,
             empname,
             design.
  ENDMETHOD.
  METHOD  set.
    empno 127.
    eMPname 'SOURAV'.
    DESIGN 'CEO'.
    CALL METHOD me->display).
  ENDMETHOD.
ENDCLASS.

DATA :ob1 TYPE REF TO lcl_emp.
start-of-selection.
  CREATE OBJECT ob1.
  OB1->SET).