SAP SD销售发票冲销BAPI:BAPI_BILLINGDOC_CANCEL1
作者:互联网
开发报表查询出销售发票,然后换调用BAPI,进行批量冲销。
代码
form frm_billingdoc_cancel using ps_data like gt_output
changing cp_subrc type sy-subrc
cp_msg type string
cp_vbeln type vbeln_vf.
data:lt_return type table of bapireturn1.
data:lt_success type table of bapivbrksuccess.
data:ls_return type bapireturn1.
data:ls_success type bapivbrksuccess.
data:lv_billingdate type bapivbrk-bill_date.
data:lv_vbeln_old type bill_doc.
data:lv_subrc type sy-subrc.
clear:lt_return[],lt_success[],lv_billingdate,lv_vbeln_old.
lv_vbeln_old = ps_data-vbeln.
lv_billingdate = ps_data-fkdat2.
call function ‘BAPI_BILLINGDOC_CANCEL1’
exporting
billingdocument = lv_vbeln_old
billingdate = lv_billingdate
tables
return = lt_return
success = lt_success.
read table lt_return into ls_return with key type = ‘E’.
if sy-subrc = 0.
call function ‘BAPI_TRANSACTION_ROLLBACK’.
cp_subrc = 1.
cp_msg = ls_return-message.
else.
call function ‘BAPI_TRANSACTION_COMMIT’
exporting
wait = ‘X’.
read table lt_success into ls_success with key ref_doc = lv_vbeln_old.
if sy-subrc = 0.
cp_vbeln = ls_success-bill_doc.
cp_msg = ‘成功’.
cp_subrc = 0.
else.
call function ‘BAPI_TRANSACTION_ROLLBACK’.
cp_subrc = 1.
cp_msg = ‘冲销失败’.
endif.
endif.
endform.
标签:BAPI,subrc,BILLINGDOC,data,CANCEL1,vbeln,lv,cp,type 来源: https://blog.csdn.net/fang2327/article/details/110276034