SAP Tutorials Blog

 


TABLES: pa0002.


PARAMETERS: pernr TYPE pa0002-pernr.


DATA: BEGIN OF stru,

      pernr TYPE pa0002-pernr,

      vorna TYPE pa0002-vorna,

      nachn TYPE pa0002-nachn,

      END OF stru.


DATA: itab LIKE TABLE OF stru,

      wa LIKE stru.


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

*       CLASS class1 DEFINITION

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

*

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

CLASS class1 DEFINITION ABSTRACT.

  PUBLIC SECTION.

    METHODS: method1.

ENDCLASS.                    "class1 DEFINITION



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

*       CLASS class1 IMPLEMENTATION

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

*

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

CLASS class1 IMPLEMENTATION.

  METHOD method1.

    WRITE: 'This is abstract class1'.

  ENDMETHOD.                                                "method1

ENDCLASS.                    "class1 IMPLEMENTATION




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

*       CLASS class2 DEFINITION

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

*

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

CLASS class2 DEFINITION INHERITING FROM class1.

  PUBLIC SECTION.

    METHODS method2.

ENDCLASS.                    "class2 DEFINITION



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

*       CLASS class2 IMPLEMENTATION

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

*

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

CLASS class2 IMPLEMENTATION.

  METHOD method2.

    SELECT * FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE itab WHERE pernr EQ pernr.

    LOOP AT itab INTO wa.

      WRITE: / wa-pernr, wa-vorna, wa-nachn.

    ENDLOOP.

  ENDMETHOD.                                                "method2

ENDCLASS.                    "class2 IMPLEMENTATION



START-OF-SELECTION.

  DATA: object1 TYPE REF TO class2.

  CREATE OBJECT object1.

  CALL METHOD: object1->method1,

               object1->method2.


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com