SAP Tutorials Blog

 


INTERFACE interface1.

*  PUBLIC SECTION.

  METHODS: interface1_method.

ENDINTERFACE.                                               "interface1


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

*       CLASS class1 DEFINITION

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

*

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

CLASS class1 DEFINITION.

  PUBLIC SECTION.

    INTERFACES: interface1.

ENDCLASS.                    "class1 DEFINITION


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

*       CLASS class1 DEFINITION

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

*

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

CLASS class2 DEFINITION.

  PUBLIC SECTION.

    INTERFACES: interface1.

ENDCLASS.                    "class1 DEFINITION


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

*       CLASS class3_friend DEFINITION

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

*

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

CLASS class3_friend DEFINITION FRIENDS class1.

  PUBLIC SECTION.

    DATA: string1 TYPE string VALUE 'string of class3_friend'.

ENDCLASS.                    "class3_friend DEFINITION


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

*       CLASS class1 IMPLEMENTATION

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

*

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

CLASS class1 IMPLEMENTATION.

  METHOD interface1~interface1_method.

    DATA: class3_friend_object TYPE REF TO class3_friend.

    CREATE OBJECT class3_friend_object.

    SKIP.

    WRITE: / 'Accessing string1 from class1 via interface1'.

    WRITE: / class3_friend_object->string1 COLOR 7.

    SKIP.

    ULINE.

    SKIP.

  ENDMETHOD.                    "interface1~interface1_method

ENDCLASS.                    "class1 IMPLEMENTATION



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

*       CLASS class2 IMPLEMENTATION

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

*

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

CLASS class2 IMPLEMENTATION.

  METHOD interface1~interface1_method.

    DATA: class3_friend_object1 TYPE REF TO class3_friend.

    CREATE OBJECT class3_friend_object1.

    WRITE: / 'Accessing string1 from class2 via interface1'.

    WRITE: / class3_friend_object1->string1 COLOR 7.

    SKIP.

    ULINE.

    SKIP.

  ENDMETHOD.                    "interface1~interface1_method

ENDCLASS.                    "class2 IMPLEMENTATION


START-OF-SELECTION.


  DATA: class1_object TYPE REF TO interface1.


  CREATE OBJECT class1_object TYPE class1.


  class1_object->interface1_method( ).


  DATA: class2_object TYPE REF TO interface1.


  CREATE OBJECT class2_object TYPE class2.


  class2_object->interface1_method( ).


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com