# abap事例

abap 示范实例 超好的东东---申明：这文章不是我写的

REPORT TEST.
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.

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.

• 博文量
13
• 访问量
14907