最后就是把我们查到的数据输出了。其实我举的这个程序到这一步时穿插了一些查询。
代码如下:
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.