REPORT ysap_parent_child_class1.
PARAMETERS : e TYPE i,
f TYPE i.
*----------------------------------------------------------------------*
* CLASS parentcls DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS parentcls DEFINITION.
PUBLIC SECTION.
DATA : a TYPE i,
b TYPE i.
METHODS: add.
PROTECTED SECTION.
DATA: c TYPE i.
ENDCLASS. "parentcls DEFINITION
*----------------------------------------------------------------------*
* CLASS parentcls IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS parentcls IMPLEMENTATION.
METHOD add.
a = e.
b = f.
c = a + b.
WRITE: 'this is parent class data'.
WRITE: c.
ENDMETHOD. "add
ENDCLASS. "parentcls IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS childcls DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS childcls DEFINITION INHERITING FROM parentcls.
PUBLIC SECTION.
METHODS: add1.
ENDCLASS. "childcls DEFINITION
*----------------------------------------------------------------------*
* CLASS childcls IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS childcls IMPLEMENTATION.
METHOD add1.
WRITE: 'this is child class data'.
WRITE: c.
ENDMETHOD. "add1
ENDCLASS. "childcls IMPLEMENTATION
START-OF-SELECTION.
DATA: parent TYPE REF TO parentcls,
child TYPE REF TO childcls.
CREATE OBJECT: parent, child.
CALL METHOD: parent->add.
Serkan AKKAVAK
Computer Engineer BSc
SAP Department Manager
Contact : serkurumsal@yandex.com
0 Comments