使用SAP ABAP编程来实现采购订单报表查询
时间: 2024-06-12 08:05:38 浏览: 186
ABAP[采购信息记录查询]绝对好例子实用.pdf
以下是一个简单的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.
阅读全文