Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CLASS

Former Member
0 Kudos

HI,

I HAVE 2 CLASS <b> A</b> AND <b>B</b> . NOW I WANT CREATE A CLASS <b>IC</b> WHICH IS INHERITENCE OF BOTH A AND B .

HOW CAN DECLARE IT ?

THANK YOU

ASHOK KUMAR

1 ACCEPTED SOLUTION

0 Kudos

Hi,

IN ABAP inherting from TWO classes is not possible.

What you can do convert one class to an interface and move the method implementation to the class 'C'.

Then Class C can implement interface 'A" and inherit class 'B'.

Regards,

Sesh

4 REPLIES 4

0 Kudos

Hi,

IN ABAP inherting from TWO classes is not possible.

What you can do convert one class to an interface and move the method implementation to the class 'C'.

Then Class C can implement interface 'A" and inherit class 'B'.

Regards,

Sesh

Former Member
0 Kudos

Hi,

here is an example to inherite one class.see this.

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.

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.

rgds,

bharat.

Former Member
0 Kudos

Hi,

please check out the following link it might be helpful to you

http://java.sun.com/docs/books/tutorial/java/concepts/inheritance.html

********please reward points if the information is helpful to you**************

KKilhavn
Active Contributor
0 Kudos

SAP decided that multiple inheritance was not needed. Worse, they also decided that overloading was not needed.

You don't say much about your case in question. Perhaps you can solve it by using interfaces. A class can implement multiple interfaces as you probably already know.

Kjetil Kilhavn (Vettug AS) - ABAP developer since Feb 2000