REPORT Y001.
TABLES: EKKO,EKET,EKPO.
* 定义内表
DATA: BEGIN OF ITAB OCCURS 0,
EBELN LIKE EKKO-EBELN,
MENGE LIKE EKPO-MENGE,
WEMNG LIKE EKET-WEMNG,
END OF ITAB.
* 定义数据
DATA: MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
WEMNG LIKE EKET-WEMNG,
EBELN LIKE EKPO-EBELN.
* 定义选择屏幕
SELECT-OPTIONS: EBELN1 FOR EKKO-EBELN,
BEDAT FOR EKKO-BEDAT,
EKGRP FOR EKKO-EKGRP.
PARAMETERS: R1 RADIOBUTTON GROUP RADI,
R2 RADIOBUTTON GROUP RADI,
R3 RADIOBUTTON GROUP RADI.
* 查询数据
SELECT K~EBELN INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM EKKO AS K
WHERE K~EBELN IN EBELN1
AND K~BEDAT IN BEDAT
AND K~EKGRP IN EKGRP.
LOOP AT ITAB.
SELECT SUM( MENGE ) INTO ITAB-MENGE FROM EKPO
WHERE EBELN EQ ITAB-EBELN.
MODIFY ITAB.
ENDLOOP.
LOOP AT ITAB.
SELECT SUM( WEMNG ) INTO ITAB-WEMNG FROM EKET
WHERE EBELN EQ ITAB-EBELN.
MODIFY ITAB.
ENDLOOP.
* 定义输出界面
TOP-OF-PAGE .
WRITE: /'采购凭证号',
22 '物料号码',
47 '采购订单数量',
77 '收到货物数量',
95 '完成标志'.
ULINE AT /1(130).
END-OF-PAGE .
START-OF-SELECTION.
* 数据输出
IF R1 = 'X'.
LOOP AT ITAB.
SELECT S~MATNR S~MENGE P~WEMNG S~EBELN
INTO (MATNR, MENGE, WEMNG, EBELN)
FROM EKPO AS S INNER JOIN EKET AS P
ON S~EBELP = P~EBELP AND S~EBELN = P~EBELN
WHERE S~EBELN = ITAB-EBELN.
IF ITAB-MENGE > ITAB-WEMNG.
WRITE: /2 EBELN,23 MATNR,41 MENGE,71 WEMNG,97 '否'.
ULINE AT /1(130).
CLEAR: EBELN,MATNR,MENGE,WEMNG.
ENDIF.
ENDSELECT.
ENDLOOP.
ELSEIF R2 = 'X'.
LOOP AT ITAB.
SELECT S~MATNR S~MENGE P~WEMNG S~EBELN
INTO (MATNR, MENGE, WEMNG, EBELN)
FROM EKPO AS S INNER JOIN EKET AS P
ON S~EBELP = P~EBELP AND S~EBELN = P~EBELN
WHERE S~EBELN = ITAB-EBELN.
IF ITAB-MENGE <= ITAB-WEMNG.
WRITE: /2 EBELN,23 MATNR,41 MENGE,71 WEMNG,97 '是'.
ULINE AT /1(130).
CLEAR: EBELN,MATNR,MENGE,WEMNG.
ENDIF.
ENDSELECT.
ENDLOOP.
ELSE.
LOOP AT ITAB.
SELECT S~MATNR S~MENGE P~WEMNG S~EBELN
INTO (MATNR, MENGE, WEMNG, EBELN)
FROM EKPO AS S INNER JOIN EKET AS P
ON S~EBELP = P~EBELP AND S~EBELN = P~EBELN
WHERE S~EBELN = ITAB-EBELN. IF ITAB-MENGE > ITAB-WEMNG.
WRITE: /2 EBELN, 23 MATNR,41 MENGE,71 WEMNG,97 '否'.
ULINE AT /1(130).
CLEAR: EBELN,MATNR,MENGE,WEMNG.
ENDIF.
ENDSELECT.
ENDLOOP.
ENDIF.
LOOP AT ITAB.
IF R3 = 'X' AND ITAB-MENGE <= ITAB-WEMNG.
SELECT S~MATNR S~MENGE P~WEMNG S~EBELN
INTO (MATNR, MENGE, WEMNG, EBELN)
FROM EKPO AS S INNER JOIN EKET AS P
ON S~EBELP = P~EBELP AND S~EBELN = P~EBELN
WHERE S~EBELN = ITAB-EBELN.
WRITE: /2 EBELN,23 MATNR,41 MENGE,71 WEMNG,97 '是'.
ULINE AT /1(130).
CLEAR: EBELN,MATNR,MENGE,WEMNG.
ENDSELECT.
ENDIF.
ENDLOOP.