‎2005 Nov 16 12:27 AM
Can anybody tell whether inheritance in supported in 4.5b ?
Thks
‎2005 Nov 16 12:37 AM
see example code in 4.6b
REPORT demo_inheritance.
CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PROTECTED SECTION.
DATA count TYPE i.
ENDCLASS.
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD.
METHOD increment.
ADD 1 TO count.
ENDMETHOD.
METHOD get.
get_value = count.
ENDMETHOD.
ENDCLASS.
CLASS counter_ten DEFINITION INHERITING FROM counter.
PUBLIC SECTION.
METHODS increment REDEFINITION.
DATA count_ten(1) TYPE c.
ENDCLASS.
CLASS counter_ten IMPLEMENTATION.
METHOD increment.
DATA modulo TYPE i.
CALL METHOD super->increment.
WRITE / count.
modulo = count MOD 10.
IF modulo = 0.
count_ten = count_ten + 1.
WRITE count_ten.
ENDIF.
ENDMETHOD.
ENDCLASS.
DATA: count TYPE REF TO counter,
number TYPE i VALUE 5.
START-OF-SELECTION.
CREATE OBJECT count TYPE counter_ten.
CALL METHOD count->set EXPORTING set_value = number.
DO 20 TIMES.
CALL METHOD count->increment.
ENDDO.
‎2005 Nov 16 12:28 AM
‎2005 Nov 16 12:34 AM
From this link it would appear that inheritance was not supported untill 46.
http://help.sap.com/saphelp_46b/helpdata/en/c8/c7f9bdaa28d3119b440060b0671acc/frameset.htm
Regards,
Rich Heilman
‎2005 Nov 16 12:35 AM
John,
SAP has not implemented inheritance in the BOR. However, it has provided subtyping and delegation, which offer an alternative way to extend R/3 functionality.
Cheers
Raghava
‎2005 Nov 16 12:37 AM
see example code in 4.6b
REPORT demo_inheritance.
CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PROTECTED SECTION.
DATA count TYPE i.
ENDCLASS.
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD.
METHOD increment.
ADD 1 TO count.
ENDMETHOD.
METHOD get.
get_value = count.
ENDMETHOD.
ENDCLASS.
CLASS counter_ten DEFINITION INHERITING FROM counter.
PUBLIC SECTION.
METHODS increment REDEFINITION.
DATA count_ten(1) TYPE c.
ENDCLASS.
CLASS counter_ten IMPLEMENTATION.
METHOD increment.
DATA modulo TYPE i.
CALL METHOD super->increment.
WRITE / count.
modulo = count MOD 10.
IF modulo = 0.
count_ten = count_ten + 1.
WRITE count_ten.
ENDIF.
ENDMETHOD.
ENDCLASS.
DATA: count TYPE REF TO counter,
number TYPE i VALUE 5.
START-OF-SELECTION.
CREATE OBJECT count TYPE counter_ten.
CALL METHOD count->set EXPORTING set_value = number.
DO 20 TIMES.
CALL METHOD count->increment.
ENDDO.
‎2005 Nov 16 12:38 AM
In 46b, yes it is supported. Not in 45b. Check this link.
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
Particularly the part where it says....
<i>
ABAP Objects makes this possible by using interfaces. Interfaces are independent structures that you can implement in a class to extend the scope of that class. The class-specific scope of a class is defined by its components and visibility sections. For example, the public components of a class define its public scope, since all of its attributes and method parameters can be addressed by all users. The protected components of a class define its scope with regard to its subclasses. <b>(However, inheritance is not supported in Release 4.5B).</b>
</i>
Regards,
Rich Heilman
‎2005 Nov 16 12:39 AM
‎2005 Nov 16 12:40 AM
‎2005 Nov 16 12:39 AM