Tuesday, August 11, 2020

Inheritance using Global class in SE24 (class 13)

 Inheritance using Global class in SE24 (class 13)

Create a super class.

 
Its attributes 
 
Create method Display to display the data.

 
 
 

 

Now creating another class and inherit the super class zcl_vehicle class and don't make it final if you want to inherit the child class to another class.


Please change the data type of colors attribute to char10.


Now create another class ZCL_BIKE ,if you want to inherit the class zcl_cycle methods.







*&---------------------------------------------------------------------*
*& Report  ZOOABAP_CL14
*& For accessing above Global Inherited classes
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZOOABAP_CL14.

DATA OB1 TYPE REF TO ZCL_CYCLE.
CREATE OBJECT OB1.
FORMAT COLOR 3.

CALL METHOD OB1->SETCYCLE.
CALL METHOD OB1->DISPLAY.

ULINE.

FORMAT COLOR 7.

DATA OB2 TYPE REF TO ZCL_BIKE.
CREATE OBJECT OB2.
FORMAT COLOR 3.
CALL METHOD OB2->SETBIKE.
CALL METHOD OB2->DISPLAY.