Code: Alles auswählen.
REPORT zrt_unklar.
"
CLASS zcl_level_0_class_1 DEFINITION
ABSTRACT
CREATE PUBLIC .
"
PUBLIC SECTION.
METHODS demo.
CLASS-METHODS class_constructor .
PROTECTED SECTION.
CLASS-DATA sv_classname TYPE seoclname .
CLASS-DATA sv_demo TYPE char20.
CLASS-DATA so_singleton TYPE REF TO zcl_level_0_class_1.
PRIVATE SECTION.
ENDCLASS.
"
CLASS zcl_level_0_class_1 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_0_class_1'.
ENDMETHOD.
METHOD demo.
WRITE: / sv_classname, sv_demo.
ENDMETHOD.
ENDCLASS.
"
"
CLASS zcl_level_1_class_1 DEFINITION
INHERITING FROM zcl_level_0_class_1
FINAL
CREATE PRIVATE .
"
PUBLIC SECTION.
CLASS-METHODS class_constructor .
CLASS-METHODS get_instance
RETURNING
VALUE(r_object) TYPE REF TO zcl_level_0_class_1.
PROTECTED SECTION.
PRIVATE SECTION.
METHODS constructor .
ENDCLASS.
"
CLASS zcl_level_1_class_1 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_1_class_1'.
ENDMETHOD.
METHOD constructor.
super->constructor( ).
ENDMETHOD.
METHOD get_instance.
CLEAR:
r_object.
"
IF so_singleton IS NOT BOUND.
so_singleton = NEW zcl_level_1_class_1( ).
sv_demo = 'Objekt Klasse 1'.
* ELSE.
"NOP
ENDIF.
r_object = so_singleton.
ENDMETHOD.
ENDCLASS.
CLASS zcl_level_1_class_2 DEFINITION
* public
INHERITING FROM zcl_level_0_class_1
FINAL
CREATE PRIVATE .
"
PUBLIC SECTION.
CLASS-METHODS class_constructor .
CLASS-METHODS get_instance
RETURNING
VALUE(r_object) TYPE REF TO zcl_level_0_class_1.
PROTECTED SECTION.
PRIVATE SECTION.
METHODS constructor .
ENDCLASS.
"
CLASS zcl_level_1_class_2 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_1_class_2'.
ENDMETHOD.
METHOD constructor.
super->constructor( ).
ENDMETHOD.
METHOD get_instance.
CLEAR:
r_object.
"
IF so_singleton IS NOT BOUND.
so_singleton = NEW zcl_level_1_class_2( ).
sv_demo = 'Objekt Klasse 2'.
* ELSE.
"NOP
ENDIF.
r_object = so_singleton.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
zcl_level_1_class_1=>get_instance( )->demo( ).
zcl_level_1_class_2=>get_instance( )->demo( ).
Code: Alles auswählen.
REPORT zrt_unklar.
"
CLASS zcl_level_0_class_1 DEFINITION
ABSTRACT
CREATE PUBLIC .
"
PUBLIC SECTION.
CLASS-METHODS demo.
CLASS-METHODS class_constructor .
PROTECTED SECTION.
CLASS-DATA sv_classname TYPE seoclname .
CLASS-DATA sv_demo TYPE char20.
* class-DATA so_singleton TYPE REF TO zcl_level_0_class_1.
PRIVATE SECTION.
ENDCLASS.
"
CLASS zcl_level_0_class_1 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_0_class_1'.
ENDMETHOD.
METHOD demo.
WRITE: / sv_classname, sv_demo.
ENDMETHOD.
ENDCLASS.
"
"
CLASS zcl_level_1_class_1 DEFINITION
INHERITING FROM zcl_level_0_class_1
FINAL
CREATE PRIVATE .
"
PUBLIC SECTION.
CLASS-METHODS class_constructor .
CLASS-METHODS get_instance
RETURNING
VALUE(r_object) TYPE REF TO zcl_level_0_class_1.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA: so_singleton TYPE REF TO zcl_level_1_class_1.
METHODS constructor .
ENDCLASS.
"
CLASS zcl_level_1_class_1 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_1_class_1'.
ENDMETHOD.
METHOD constructor.
super->constructor( ).
ENDMETHOD.
METHOD get_instance.
CLEAR:
r_object.
"
IF so_singleton IS NOT BOUND.
so_singleton = NEW zcl_level_1_class_1( ).
sv_demo = 'Objekt Klasse 1'.
* ELSE.
"NOP
ENDIF.
r_object = so_singleton.
ENDMETHOD.
ENDCLASS.
CLASS zcl_level_1_class_2 DEFINITION
* public
INHERITING FROM zcl_level_0_class_1
FINAL
CREATE PRIVATE .
"
PUBLIC SECTION.
CLASS-METHODS class_constructor .
CLASS-METHODS get_instance
RETURNING
VALUE(r_object) TYPE REF TO zcl_level_0_class_1.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA: so_singleton TYPE REF TO zcl_level_1_class_2.
METHODS constructor .
ENDCLASS.
"
CLASS zcl_level_1_class_2 IMPLEMENTATION.
METHOD class_constructor.
sv_classname = 'zcl_level_1_class_2'.
ENDMETHOD.
METHOD constructor.
super->constructor( ).
ENDMETHOD.
METHOD get_instance.
CLEAR:
r_object.
"
IF so_singleton IS NOT BOUND.
so_singleton = NEW zcl_level_1_class_2( ).
sv_demo = 'Objekt Klasse 2'.
* ELSE.
"NOP
ENDIF.
r_object = so_singleton.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
zcl_level_1_class_1=>get_instance( )->demo( ).
zcl_level_1_class_2=>get_instance( )->demo( ).