使用SAP ABAP编程来实现采购订单报表查询
时间: 2024-06-12 18:05:38 浏览: 161
以下是一个简单的SAP ABAP程序,用于查询采购订单报表:
REPORT ZPURCHASE_ORDERS.
TABLES: EKKO, EKPO.
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_ebeln TYPE ekko-ebeln OBLIGATORY,
p_bukrs TYPE ekko-bukrs.
SELECTION-SCREEN END OF BLOCK b1.
*Output
START-OF-SELECTION.
WRITE: / 'Purchase Order Report'.
WRITE: / 'Purchase Order Number:', p_ebeln.
WRITE: / 'Company Code:', p_bukrs.
SELECT SINGLE bukrs lifnr werks ekko~ebeln ekko~bedat
INTO (p_bukrs, p_lifnr, p_werks, p_ebeln, p_bedat)
FROM ekko
WHERE ebeln = p_ebeln AND bukrs = p_bukrs.
IF sy-subrc NE 0.
WRITE: / 'Purchase order does not exist.'.
ELSE.
WRITE: / 'Vendor:', p_lifnr,
'Plant:', p_werks,
'Created On:', p_bedat.
SELECT ebeln ebelp matnr werks menge meins netpr
INTO TABLE @DATA(it_ekpo)
FROM ekpo
WHERE ebeln = p_ebeln.
IF it_ekpo[] IS INITIAL.
WRITE: / 'No items found for purchase order.'.
ELSE.
WRITE: / 'Purchase Order Items:'.
WRITE: / 'Item', 'Material', 'Plant', 'Quantity', 'Unit', 'Net Price'.
LOOP AT it_ekpo INTO DATA(wa_ekpo).
WRITE: / wa_ekpo-ebelp, wa_ekpo-matnr,
wa_ekpo-werks, wa_ekpo-menge, wa_ekpo-meins,
wa_ekpo-netpr.
ENDLOOP.
ENDIF.
ENDIF.
END-OF-SELECTION.