DEMO:VF01 、VF04外向交货单开票BAPI_BILLINGDOC_CREATEMULTIPLE_赋值

DEMO:VF01 、VF04外向交货单开票BAPI_BILLINGDOC_CREATEMULTIPLE_赋值_02

DEMO:VF01 、VF04外向交货单开票BAPI_BILLINGDOC_CREATEMULTIPLE_赋值_03

DEMO:VF01 、VF04外向交货单开票BAPI_BILLINGDOC_CREATEMULTIPLE_赋值_04

PARAMETERS p_dn TYPE vbeln_vl.
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-itm_number = 10.
ls_billingdatain-ref_doc = p_so."参考单据的单据编号
ls_billingdatain-ref_item = 10.
ls_billingdatain-ref_doc_ca = 'J' . "先期SD凭证的凭证类别
ls_billingdatain-salesorg = 'LM00'.
ls_billingdatain-distr_chan = '10'.
ls_billingdatain-division = '10'.
ls_billingdatain-plant = 'LM00'.
ls_billingdatain-material = 'LMTEST'.
ls_billingdatain-req_qty = 5.
ls_billingdatain-sales_unit = 'EA'.
APPEND ls_billingdatain TO lt_billingdatain.
ls_billingdatain-doc_number = p_dn ."."销售凭证
ls_billingdatain-itm_number = 10.
ls_billingdatain-ref_doc = p_so."."参考单据的单据编号
ls_billingdatain-ref_item = 10.
ls_billingdatain-ref_doc_ca = 'J' . "先期SD凭证的凭证类别
ls_billingdatain-salesorg = 'LM00'.
ls_billingdatain-distr_chan = '10'.
ls_billingdatain-division = '10'.
ls_billingdatain-plant = 'LM00'.
ls_billingdatain-material = 'LMTEST'.
ls_billingdatain-req_qty = 5.
ls_billingdatain-sales_unit = 'EA'.
APPEND ls_billingdatain TO lt_billingdatain.
CLEAR: ls_billingdatain.
* ENDLOOP.
CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
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'.
另外VF04是功能程序,可以copy出来根据需要修改