FOR ALL ENTRIES ( JOIN TABLE)
----------------------------------------------------------*
*& Report ZREPOR_FOR_ALL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZREPOR_FOR_ALL.
TABLES: MARA.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
DATA: BEGIN OF IMARA OCCURS 0,
MATNR TYPE MARA-MATNR,
MBRSH TYPE MARA-MBRSH,
MTART TYPE MARA-MTART,
END OF IMARA.
DATA: BEGIN OF IMARC OCCURS 0,
MATNR TYPE MARC-MATNR,
WERKS TYPE MARC-WERKS,
END OF IMARC.
DATA: BEGIN OF FINAL OCCURS 0,
MATNR TYPE MARA-MATNR,
MBRSH TYPE MARA-MBRSH,
MTART TYPE MARA-MTART,
WERKS TYPE MARC-WERKS,
END OF FINAL.
SELECT MATNR MBRSH MTART FROM MARA
INTO TABLE IMARA WHERE MATNR IN S_MATNR.
IF NOT IMARA[] IS INITIAL.
SELECT MATNR WERKS FROM MARC
INTO TABLE IMARC
FOR ALL ENTRIES IN IMARA
WHERE MATNR = IMARA-MATNR.
SORT IMARC BY MATNR.
LOOP AT IMARA.
READ TABLE IMARC WITH KEY MATNR = IMARA-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE: IMARA-MATNR TO FINAL-MATNR,
IMARA-MBRSH TO FINAL-MBRSH.
MOVE: IMARA-MTART TO FINAL-MTART.
MOVE: IMARC-WERKS TO FINAL-WERKS.
APPEND FINAL.
CLEAR: FINAL.
CLEAR: IMARA.
CLEAR: IMARC.
ENDIF.
ENDLOOP.
LOOP AT FINAL.
WRITE:/ FINAL-MATNR,
FINAL-MBRSH,
FINAL-MTART,
FINAL-WERKS.
ENDLOOP.
ENDIF.
SAVE AND ACTIVE
RUN
Comments
Post a Comment