SAP Tutorials Blog

 


INTERFACE interface1.

  METHODS method1.

ENDINTERFACE.                                               "interface1


*----------------------------------------------------------------------*

*       CLASS class1 DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS class1 DEFINITION.

  PUBLIC SECTION.

    INTERFACES interface1.

ENDCLASS.                    "class1 DEFINITION


*----------------------------------------------------------------------*

*       CLASS class1 IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS class1 IMPLEMENTATION.

  METHOD interface1~method1.

    WRITE:/ 'method1 from claas1' COLOR 6.

  ENDMETHOD.                    "interface1~method1

ENDCLASS.                    "class1 IMPLEMENTATION


*----------------------------------------------------------------------*

*       CLASS class2 DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS class2 DEFINITION.

  PUBLIC SECTION.

    INTERFACES interface1.

ENDCLASS.                    "class2 DEFINITION


*----------------------------------------------------------------------*

*       CLASS class2 IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS class2 IMPLEMENTATION.

  METHOD interface1~method1.

    WRITE:/ 'method1 from class2' COLOR 7.

  ENDMETHOD.                    "interface1~method1

ENDCLASS.                    "class2 IMPLEMENTATION


START-OF-SELECTION.

  DATA: object1 TYPE REF TO class1,

        object2 TYPE REF TO class2,

        object TYPE REF TO interface1.


  CREATE OBJECT: object1, object2.


  object = object1.

  CALL METHOD: object->method1.

  object = object2.

  CALL METHOD object->method1.



Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com