Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Execution of class_constructors in subclass

hi all, i'm new to abap objects but the testing the code below puzzles me. can anyone explain why if i execute WRITE b=>d, the sub class_constructor is not executed? i would expect that after executing the super c-c, the sub c-c is next. as expected, only the super c-c is executed for WRITE a=>d.

i had read, once a subclass is addressed, the c-c is executed if it hasn't been yet, after all unperformed super c-c's are executed. but why when addressing b=>d not perform it?

CLASS a DEFINITION.

PUBLIC SECTION.

CLASS-DATA d TYPE c VALUE 'D'.

CLASS-METHODS class_constructor.

ENDCLASS.

CLASS b DEFINITION INHERITING FROM a.

PUBLIC SECTION.

CLASS-METHODS class_constructor..

ENDCLASS.

CLASS a IMPLEMENTATION.

METHOD class_constructor.

WRITE:/ 'Superclass constructor'.

ENDMETHOD.

ENDCLASS.

CLASS b IMPLEMENTATION.

METHOD class_constructor.

WRITE:/ 'Subclass constructor'.

ENDMETHOD.

ENDCLASS.

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question