Application Development and Automation 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: 
Read only

example on interfaces

Former Member
0 Likes
528

hi all,

send the simple example on interfaces using abap objects.

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
475

interface inter_1.

methods: method1.

endinterface.

class clas1 definition.

public section.

interfaces: inter_1.

endclass.

class clas1 implementation.

method inter_1~method1.

*method code

endmethod.

endclass.

Regards,

Sesh

Message was edited by:

Seshatalpasai Madala

4 REPLIES 4
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
476

interface inter_1.

methods: method1.

endinterface.

class clas1 definition.

public section.

interfaces: inter_1.

endclass.

class clas1 implementation.

method inter_1~method1.

*method code

endmethod.

endclass.

Regards,

Sesh

Message was edited by:

Seshatalpasai Madala

Read only

0 Likes
475

please send the code which will work completely.but u r code is not working.

Read only

Former Member
0 Likes
475

Check out in this

http://www.sapgenie.com/abap/OO/eg.htm

Regards,

Santosh

Read only

Former Member
0 Likes
475

Hi venkat,

The sample code i have attached is simple and its working..here we use a interface called status and two classes implementing it...

REPORT demo_interface.

INTERFACE status.

METHODS write.

ENDINTERFACE.

CLASS counter DEFINITION.

PUBLIC SECTION.

INTERFACES status.

METHODS increment.

PRIVATE SECTION.

DATA count TYPE i.

ENDCLASS.

CLASS counter IMPLEMENTATION.

METHOD status~write.

WRITE: / 'Count in counter is', count.

ENDMETHOD.

METHOD increment.

ADD 1 TO count.

ENDMETHOD.

ENDCLASS.

CLASS bicycle DEFINITION.

PUBLIC SECTION.

INTERFACES status.

METHODS drive.

PRIVATE SECTION.

DATA speed TYPE i.

ENDCLASS.

CLASS bicycle IMPLEMENTATION.

METHOD status~write.

WRITE: / 'Speed of bicycle is', speed.

ENDMETHOD.

METHOD drive.

ADD 10 TO speed.

ENDMETHOD.

ENDCLASS.

DATA: count TYPE REF TO counter,

bike TYPE REF TO bicycle,

status TYPE REF TO status,

status_tab TYPE TABLE OF REF TO status.

START-OF-SELECTION.

CREATE OBJECT: count, bike.

DO 5 TIMES.

CALL METHOD: count->increment,

bike->drive.

ENDDO.

APPEND: count TO status_tab,

bike TO status_tab.

LOOP AT status_tab INTO status.

CALL METHOD status->write.

ENDLOOP.

  • hope i have resolved ur isssue

  • reward useful suggestions..

regards,

Rajkumar.G.