Level-3 Interactive Report (Tables used: EKKO, EKPO and MAKT)
REPORT Z_INTERACTIVE_LEVEL3.
TABLES: EKKO, EKPO, MAKT.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE ELIFN,
BUKRS TYPE BUKRS,
END OF TY_EKKO,
BEGIN OF TY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
LGORT TYPE LGORT_D,
MATKL TYPE MATKL,
MENGE TYPE BSTMG,
END OF TY_EKPO,
BEGIN OF TY_MAKT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MAKT.
DATA: T_EKKO TYPE STANDARD TABLE OF TY_EKKO,
T_EKPO TYPE STANDARD TABLE OF TY_EKPO,
T_MAKT TYPE STANDARD TABLE OF TY_MAKT.
DATA: W_EKKO TYPE TY_EKKO,
W_EKPO TYPE TY_EKPO,
W_MAKT TYPE TY_MAKT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:PURCHASE FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
SELECT EBELN LIFNR BUKRS
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN PURCHASE.
IF T_EKKO IS NOT INITIAL.
SELECT EBELN EBELP MATNR LGORT MATKL MENGE
FROM EKPO
INTO TABLE T_EKPO FOR ALL ENTRIES IN T_EKKO
WHERE EBELN = T_EKKO-EBELN.
SORT T_EKPO.
IF T_EKPO IS NOT INITIAL.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE T_MAKT FOR ALL ENTRIES IN T_EKPO
WHERE MATNR = T_EKPO-MATNR AND SPRAS = SY-LANGU.
ENDIF.
ENDIF.
LOOP AT T_EKKO INTO W_EKKO.
WRITE :/1 W_EKKO-EBELN,
20 W_EKKO-LIFNR,
30 W_EKKO-BUKRS.
HIDE W_EKKO.
ENDLOOP.
TOP-OF-PAGE.
WRITE: 'PURCHASE ORDER DETAILS'.
ULINE.
WRITE : /1 'PURCHASE',
20 'VENDOR',
30 'COMPANY CODE'.
ULINE .
AT LINE-SELECTION.
IF SY-LSIND = 1.
WRITE : /1 SY-VLINE, 'ITEM NO' ,
20 SY-VLINE, 'MATERIAL NO',
40 SY-VLINE, 'STORAGE LOCATION',
60 SY-VLINE, 'PURCHASE ORDER',
80 SY-VLINE, 'MATERIAL GROUP',
100 SY-VLINE, 'PURCHASE NO',
120 SY-VLINE.
ULINE.
LOOP AT T_EKPO INTO W_EKPO WHERE EBELN = W_EKKO-EBELN.
WRITE: 1 SY-VLINE, W_EKPO-EBELP,
20 SY-VLINE, W_EKPO-MATNR,
40 SY-VLINE, W_EKPO-LGORT,
60 SY-VLINE, W_EKPO-MENGE,
80 SY-VLINE, W_EKPO-MATKL,
100 SY-VLINE, W_EKPO-EBELN,
120 SY-VLINE.
HIDE W_EKPO.
ENDLOOP.
ULINE.
ENDIF.
IF SY-LSIND = 2.
WRITE:/ SY-VLINE, 'MATERIAL NUMBER',30
SY-VLINE, 'MATERIAL DESCRIPTION',70
SY-VLINE.
ULINE.
LOOP AT T_MAKT INTO W_MAKT WHERE MATNR = W_EKPO-MATNR.
WRITE:/ SY-VLINE, W_MAKT-MATNR, 30
SY-VLINE, W_MAKT-MAKTX, 70
SY-VLINE.
HIDE W_MAKT.
ULINE.
ENDLOOP.
ENDIF.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: 'SALES ORDER DETAILS'.
ULINE.
TABLES: EKKO, EKPO, MAKT.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE ELIFN,
BUKRS TYPE BUKRS,
END OF TY_EKKO,
BEGIN OF TY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
LGORT TYPE LGORT_D,
MATKL TYPE MATKL,
MENGE TYPE BSTMG,
END OF TY_EKPO,
BEGIN OF TY_MAKT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MAKT.
DATA: T_EKKO TYPE STANDARD TABLE OF TY_EKKO,
T_EKPO TYPE STANDARD TABLE OF TY_EKPO,
T_MAKT TYPE STANDARD TABLE OF TY_MAKT.
DATA: W_EKKO TYPE TY_EKKO,
W_EKPO TYPE TY_EKPO,
W_MAKT TYPE TY_MAKT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:PURCHASE FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
SELECT EBELN LIFNR BUKRS
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN PURCHASE.
IF T_EKKO IS NOT INITIAL.
SELECT EBELN EBELP MATNR LGORT MATKL MENGE
FROM EKPO
INTO TABLE T_EKPO FOR ALL ENTRIES IN T_EKKO
WHERE EBELN = T_EKKO-EBELN.
SORT T_EKPO.
IF T_EKPO IS NOT INITIAL.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE T_MAKT FOR ALL ENTRIES IN T_EKPO
WHERE MATNR = T_EKPO-MATNR AND SPRAS = SY-LANGU.
ENDIF.
ENDIF.
LOOP AT T_EKKO INTO W_EKKO.
WRITE :/1 W_EKKO-EBELN,
20 W_EKKO-LIFNR,
30 W_EKKO-BUKRS.
HIDE W_EKKO.
ENDLOOP.
TOP-OF-PAGE.
WRITE: 'PURCHASE ORDER DETAILS'.
ULINE.
WRITE : /1 'PURCHASE',
20 'VENDOR',
30 'COMPANY CODE'.
ULINE .
AT LINE-SELECTION.
IF SY-LSIND = 1.
WRITE : /1 SY-VLINE, 'ITEM NO' ,
20 SY-VLINE, 'MATERIAL NO',
40 SY-VLINE, 'STORAGE LOCATION',
60 SY-VLINE, 'PURCHASE ORDER',
80 SY-VLINE, 'MATERIAL GROUP',
100 SY-VLINE, 'PURCHASE NO',
120 SY-VLINE.
ULINE.
LOOP AT T_EKPO INTO W_EKPO WHERE EBELN = W_EKKO-EBELN.
WRITE: 1 SY-VLINE, W_EKPO-EBELP,
20 SY-VLINE, W_EKPO-MATNR,
40 SY-VLINE, W_EKPO-LGORT,
60 SY-VLINE, W_EKPO-MENGE,
80 SY-VLINE, W_EKPO-MATKL,
100 SY-VLINE, W_EKPO-EBELN,
120 SY-VLINE.
HIDE W_EKPO.
ENDLOOP.
ULINE.
ENDIF.
IF SY-LSIND = 2.
WRITE:/ SY-VLINE, 'MATERIAL NUMBER',30
SY-VLINE, 'MATERIAL DESCRIPTION',70
SY-VLINE.
ULINE.
LOOP AT T_MAKT INTO W_MAKT WHERE MATNR = W_EKPO-MATNR.
WRITE:/ SY-VLINE, W_MAKT-MATNR, 30
SY-VLINE, W_MAKT-MAKTX, 70
SY-VLINE.
HIDE W_MAKT.
ULINE.
ENDLOOP.
ENDIF.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: 'SALES ORDER DETAILS'.
ULINE.
No comments:
Post a Comment