BAPI_INCOMINGINVOICE_CREATE如何使用
时间: 2023-08-02 22:07:50 浏览: 297
BAPI_INCOMINGINVOICE_CREATE是一个SAP标准的BAPI,用于创建应付账款发票。以下是使用BAPI_INCOMINGINVOICE_CREATE的步骤:
1. 准备输入参数数据:需要创建发票的供应商、发票行项目数据、发票头信息等。
2. 调用BAPI_INCOMINGINVOICE_CREATE:将输入参数传递给BAPI_INCOMINGINVOICE_CREATE,调用该BAPI创建发票。
3. 检查返回值:BAPI返回一个结构体,其中包含了创建发票的结果信息。需要检查返回值,以确定发票是否成功创建。
以下是一个简单的ABAP代码示例,演示如何使用BAPI_INCOMINGINVOICE_CREATE来创建发票:
```
DATA: wa_head LIKE bapi_incinv_create_header,
wa_item LIKE bapi_incinv_create_item,
it_item TYPE STANDARD TABLE OF bapi_incinv_create_item WITH HEADER LINE.
* 准备输入参数数据
wa_head-companycode = '1000'.
wa_head-documentdate = sy-datum.
wa_head-pstngdate = sy-datum.
wa_head-duedate = sy-datum + 30.
wa_head-vendor = '10000001'.
wa_head-purch_org = '1000'.
wa_head-purch_group = '001'.
wa_head-currency = 'USD'.
wa_item-po_item = '00010'.
wa_item-gross_amount = '100.00'.
wa_item-currency = 'USD'.
wa_item-quantity = 1.
wa_item-orderid = '1000'.
wa_item-material = 'M-0001'.
wa_item-short_text = 'Test item'.
APPEND wa_item TO it_item.
* 调用BAPI_INCOMINGINVOICE_CREATE
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = wa_head
TABLES
invoicedata = it_item.
* 检查返回值
IF sy-subrc <> 0.
MESSAGE 'Failed to create invoice.' TYPE 'E'.
ELSE.
MESSAGE 'Invoice created successfully.' TYPE 'S'.
ENDIF.
```
在实际使用中,需要根据具体业务需求,调整输入参数数据的内容。同时,还需要注意,BAPI_INCOMINGINVOICE_CREATE可能会抛出多种异常情况,需要对这些异常情况进行处理。
阅读全文