![DEMO:针对销售订单的贷项凭证开票BAPI_BILLINGDOC_CREATEMULTIPLE DEMO:针对销售订单的贷项凭证开票BAPI_BILLINGDOC_CREATEMULTIPLE](https://i-blog.csdnimg.cn/blog_migrate/d83c3bbcec26c11b6cb8055981dde3e5.jpeg)
开票 ,冲销,再开票,VBFA和VBRK去查看
如果VF01 如果不输入日期,默认是读取订单上的开票日期
![DEMO:针对销售订单的贷项凭证开票BAPI_BILLINGDOC_CREATEMULTIPLE DEMO:针对销售订单的贷项凭证开票BAPI_BILLINGDOC_CREATEMULTIPLE](https://i-blog.csdnimg.cn/blog_migrate/03530f190fad58085de38df852c759da.jpeg)
*&---------------------------------------------------------------------*
*& Report ZLM_VF01_02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zdemo_vf01.
PARAMETERS p_so TYPE vbeln_va.
DATA: lt_billingdatain TYPE TABLE OF bapivbrk,
ls_billingdatain TYPE bapivbrk,
lt_success TYPE TABLE OF bapivbrksuccess,
ls_success TYPE bapivbrksuccess,
lt_return TYPE TABLE OF bapiret1,
ls_return TYPE bapiret1.
CLEAR lt_billingdatain[].
*ls_billingdatain-ref_doc_ca = 'J' . "先期SD凭证的凭证类别
*G 合同
*H 退货
*I 免费订单
*J 交货
*K 贷项凭单请求
*L 借项凭单请求
*M 发票
*N 取消发票
*O 贷项凭单
** BAPI赋值
* LOOP AT tp_din_item INTO ls_din_item.
* lv_index = lv_index 1.
*ls_billingdatain-doc_number = p_dn ."销售凭证
ls_billingdatain-doc_number = p_so ."销售凭证
ls_billingdatain-itm_number = 10.
ls_billingdatain-ref_doc = p_so."参考单据的单据编号
ls_billingdatain-ref_item = 10.
ls_billingdatain-ref_doc_ca = 'K' . "先期SD凭证的凭证类别
ls_billingdatain-salesorg = 'S600'.
ls_billingdatain-distr_chan = '10'.
ls_billingdatain-division = '00'.
ls_billingdatain-plant = 'S600'.
*ls_billingdatain-material = 'XSWPTEST'.
*ls_billingdatain-req_qty = 1.
ls_billingdatain-sales_unit = 'EA'.
APPEND ls_billingdatain TO lt_billingdatain.
*
*
CLEAR: ls_billingdatain.
* ENDLOOP.
DATA:creatordatain LIKE bapicreatordata.
creatordatain-created_by = sy-uname.
creatordatain-created_on = sy-datum.
CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
EXPORTING
creatordatain = creatordatain
TABLES
billingdatain = lt_billingdatain
* conditiondatain = lt_conditiondatain
* CCARDDATAIN =
* TEXTDATAIN =
* ERRORS =
return = lt_return
success = lt_success
.
*
READ TABLE lt_success INTO ls_success INDEX 1.
WRITE ls_success-bill_doc.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.