*&---------------------------------------------------------------------*
*& Report ZOOABAP_CL8
*& Friend Class Concept
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zooabap_cl8.
CLASS zlcl_emp DEFINITION DEFERRED. "Definition deffered or we can forward declaration
CLASS zlcl_customer DEFINITION FRIENDS zlcl_emp.
PUBLIC SECTION.
METHODS m1.
PROTECTED SECTION.
METHODS m2.
PRIVATE SECTION .
METHODS m3.
ENDCLASS.
CLASS zlcl_customer IMPLEMENTATION.
METHOD m1.
WRITE : /'Inside the PUBLIC Method M1 of class zlcl_customer.........'.
ENDMETHOD.
METHOD m2.
WRITE : /'Inside the PROTECTED Method M2 of class Zlcl_customer.........'.
ENDMETHOD.
METHOD m3.
WRITE : /'Inside the PRIVATE Method M3 of class zlcl_customer.........'.
ENDMETHOD.
ENDCLASS.
CLASS zlcl_emp DEFINITION.
PUBLIC SECTION.
METHODS m4.
ENDCLASS.
CLASS zlcl_emp IMPLEMENTATION.
METHOD m4.
WRITE : /'Inside the Public Method of M4 of class Zlcl_Emp......'.
*--------Now creating object : for class ZLCL_CUSTOMER inside zlcl_emp-------------*
DATA : ob TYPE REF TO zlcl_customer.
CREATE OBJECT ob .
CALL METHOD ob->m1. "accessing public class method
CALL METHOD ob->m2. "accessing protected class method
CALL METHOD ob->m3. "accessing private class method
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: ob1 TYPE REF TO zlcl_emp.
CREATE OBJECT ob1.
CALL METHOD ob1->m4."calling friend class method