Constructor Sequence Example
*&---------------------------------------------------------------------*
*& Report YTEST2_OOABAP
*&
*&---------------------------------------------------------------------*
*& Developed By Debesh
*&
*&---------------------------------------------------------------------*
REPORT ytest2_ooabap.
*----------------------------------------------------------------------*
* CLASS First_class DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS first_class DEFINITION.
PUBLIC SECTION.
METHODS : constructor.
CLASS-METHODS:class_constructor.
ENDCLASS. "First_class DEFINITION
*----------------------------------------------------------------------*
* CLASS Second_class DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS second_class DEFINITION INHERITING FROM first_class.
PUBLIC SECTION.
METHODS : constructor.
CLASS-METHODS:class_constructor.
ENDCLASS. "Second_class DEFINITION
*----------------------------------------------------------------------*
* CLASS first_class IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS first_class IMPLEMENTATION.
METHOD constructor.
NEW-LINE.
WRITE : 'This is FIRST_CLASS CONSTRUCTOR'.
ENDMETHOD. "constructor
METHOD class_constructor.
NEW-LINE.
WRITE : 'This is FIRST_CLASS CLASS CONSTRUCTOR'.
ENDMETHOD. "class_constructor
ENDCLASS. "first_class IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS first_class IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS second_class IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
NEW-LINE.
WRITE : 'This is SECOND_CLASS CONSTRUCTOR'.
ENDMETHOD. "constructor
METHOD class_constructor.
NEW-LINE.
WRITE : 'This is SECOND_CLASS CLASS CONSTRUCTOR'.
ENDMETHOD. "class_constructor
ENDCLASS. "first_class IMPLEMENTATION
START-OF-SELECTION.
DATA : lo_first TYPE REF TO first_class.
DATA : lo_second TYPE REF TO second_class.
CREATE OBJECT lo_second.
OUTPUT
OO ABAP Test Program
This is FIRST_CLASS CLASS CONSTRUCTOR
This is SECOND_CLASS CLASS CONSTRUCTOR
This is FIRST_CLASS CONSTRUCTOR
This is SECOND_CLASS CONSTRUCTOR
No comments:
Post a Comment