REPORT znested_test.
TABLES: ekko, ekpo.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_ebeln FOR ekko-ebeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------*
* INTERFACE it1
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
INTERFACE it1.
METHODS: mit1, mit2.
ENDINTERFACE. "it1
*----------------------------------------------------------------------*
* INTERFACE it2
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
INTERFACE it2.
METHODS: mit1, mit2.
INTERFACES it1.
ENDINTERFACE. "it2
*----------------------------------------------------------------------*
* CLASS cls DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cls DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
lifnr TYPE ekko-lifnr,
END OF ty_ekko,
BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
END OF ty_ekpo,
BEGIN OF ty_out,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
bukrs TYPE ekko-bukrs,
lifnr TYPE ekko-lifnr,
END OF ty_out.
DATA: wa_ekko TYPE ty_ekko,
wa_ekpo TYPE ty_ekpo,
wa_out TYPE ty_out,
it_ekko TYPE STANDARD TABLE OF ty_ekko,
it_ekpo TYPE STANDARD TABLE OF ty_ekpo,
it_out TYPE STANDARD TABLE OF ty_out.
INTERFACES it2.
ENDCLASS. "cls DEFINITION
*----------------------------------------------------------------------*
* CLASS cls IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cls IMPLEMENTATION.
METHOD it1~mit1.
SELECT ebeln bukrs lifnr FROM ekko INTO TABLE it_ekko
WHERE ebeln IN s_ebeln.
IF sy-subrc = 0.
SORT it_ekko BY ebeln.
ELSE.
MESSAGE 'Purchase Order Doesn''t Exist' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDMETHOD. "it1~mit1
METHOD it1~mit2.
SELECT ebeln ebelp matnr werks lgort
FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDMETHOD. "it1~mit2
METHOD it2~mit1.
IF it_ekpo IS NOT INITIAL.
LOOP AT it_ekpo INTO wa_ekpo.
wa_out-ebeln = wa_ekpo-ebeln.
wa_out-ebelp = wa_ekpo-ebelp.
wa_out-matnr = wa_ekpo-matnr.
wa_out-werks = wa_ekpo-werks.
wa_out-lgort = wa_ekpo-lgort.
READ TABLE it_ekko INTO wa_ekko
WITH KEY ebeln = wa_ekpo-ebeln BINARY SEARCH.
IF sy-subrc = 0.
wa_out-bukrs = wa_ekko-bukrs.
wa_out-lifnr = wa_ekko-lifnr.
ENDIF.
APPEND wa_out TO it_out.
CLEAR: wa_out, wa_ekko, wa_ekpo.
ENDLOOP.
ENDIF.
ENDMETHOD. "it2~mit1
METHOD it2~mit2.
IF it_out IS NOT INITIAL.
LOOP AT it_out INTO wa_out.
AT FIRST.
WRITE: / 'Purchase Order',
18 'Item',
26 'Material',
48 'Plant',
55 'Storage',
65 'Company',
75 'Vendor'.
ULINE.
SKIP.
ENDAT.
WRITE: / wa_out-ebeln,
18 wa_out-ebelp,
26 wa_out-matnr,
48 wa_out-werks,
55 wa_out-lgort,
65 wa_out-bukrs,
75 wa_out-lifnr.
ENDLOOP.
ENDIF.
ENDMETHOD. "it2~mit2
ENDCLASS. "cls IMPLEMENTATION
START-OF-SELECTION.
DATA obj TYPE REF TO cls.
CREATE OBJECT obj.
CALL METHOD: obj->it1~mit1,
obj->it1~mit2,
obj->it2~mit1,
obj->it2~mit2.
No comments:
Post a Comment