*判断内表是否为空
IF NOT ITAB_MATNR[] IS INITIAL.
*删除内表中的重复数据
DELETE ADJACENT DUPLICATES FROM ITAB_MATNR COMPARING MATNR.
*抽取数据
SELECT P~MATNR E~MENGE E~WEMNG
INTO TABLE ITAB_PO
FROM EKPO AS P INNER JOIN EKET AS E
ON P~EBELN = E~EBELN
AND P~EBELP = E~EBELP
FOR ALL ENTRIES IN ITAB_MATNR
WHERE MATNR = ITAB_MATNR-MATNR.
ENDIF.