*&---------------------------------------------------------------------*
*& Report YSAP_LOCAL_FRIENDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_local_friends.
* simple demo for friends.....
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 .
PUBLIC SECTION.
METHODS method1.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class2 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class2 DEFINITION FRIENDS class1.
PRIVATE SECTION.
DATA: string1 TYPE string VALUE 'This is written using friends class'.
ENDCLASS. "class2 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD method1.
DATA: object_friend TYPE REF TO class2.
CREATE OBJECT: object_friend.
WRITE: / object_friend->string1 COLOR 6.
SKIP.
ULINE.
SKIP.
SELECT * FROM pa0002
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE pernr EQ pernr.
WRITE: 'This is From parent class' COLOR 7.
LOOP AT itab INTO wa.
WRITE:/ wa-pernr, wa-vorna, wa-nachn.
ENDLOOP.
ENDMETHOD. "method1
ENDCLASS. "class1 IMPLEMENTATION
START-OF-SELECTION.
DATA: object1 TYPE REF TO class1.
CREATE OBJECT: object1.
CALL METHOD object1->method1.
*& Report YSAP_LOCAL_FRIENDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_local_friends.
* simple demo for friends.....
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 .
PUBLIC SECTION.
METHODS method1.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class2 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class2 DEFINITION FRIENDS class1.
PRIVATE SECTION.
DATA: string1 TYPE string VALUE 'This is written using friends class'.
ENDCLASS. "class2 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD method1.
DATA: object_friend TYPE REF TO class2.
CREATE OBJECT: object_friend.
WRITE: / object_friend->string1 COLOR 6.
SKIP.
ULINE.
SKIP.
SELECT * FROM pa0002
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE pernr EQ pernr.
WRITE: 'This is From parent class' COLOR 7.
LOOP AT itab INTO wa.
WRITE:/ wa-pernr, wa-vorna, wa-nachn.
ENDLOOP.
ENDMETHOD. "method1
ENDCLASS. "class1 IMPLEMENTATION
START-OF-SELECTION.
DATA: object1 TYPE REF TO class1.
CREATE OBJECT: object1.
CALL METHOD object1->method1.
No comments:
Post a Comment