Google Search - Blog...........

ABAP - OOPS: Use Of Abstract Methods From Interface In Method Programming.

report ysubdel .

interface i1 .
methods : m1 ,
m2 .
endinterface.

class c1 definition abstract.
public section.
interfaces : I1 abstract methods m2 .
endclass.

class c1 implementation.
method i1~m1.
write:/5 'I am m1 in c1'.
endmethod.
endclass.

class c2 definition inheriting from c1.
public section.
methods : i1~m2 redefinition.
endclass.

class c2 implementation.
method : i1~m2.
write:/5 'I am m2 in c2'.
endmethod.
endclass.

start-of-selection.
data : oref2 type ref to c2 .
create object : oref2.
call method : oref2->i1~m1 ,
oref2->i1~m2.

Output:

I am m1 in c1
I am m2 in c2

No comments:

Post a Comment