本文主要是介绍ABAP 创建/删除预制发票,贷方凭证(MIR7),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
创建预制发票使用的BAPI:BAPI_INCOMINGINVOICE_PARK
删除预制发票的BAPI:BAPI_INCOMINGINVOICE_DELETE
这是记录下写业务程序的基本架子。我后续复制方便。
创建预制发票源代码
"BAPI的结构
DATA: ls_headerdata TYPE bapi_incinv_create_header.
DATA: lv_invoicedocnumber LIKE bapi_incinv_fld-inv_doc_no.
DATA: lv_fiscalyear LIKE bapi_incinv_fld-fisc_year.
DATA: lt_itemdata TYPE STANDARD TABLE OF bapi_incinv_create_item,ls_itemdata TYPE bapi_incinv_create_item.
DATA: lt_taxdata TYPE STANDARD TABLE OF bapi_incinv_create_tax,ls_taxdata TYPE bapi_incinv_create_tax.
DATA: lt_glaccountdata TYPE STANDARD TABLE OF bapi_incinv_create_gl_account,ls_glaccountdata TYPE bapi_incinv_create_gl_account.
DATA: lt_extensionin TYPE TABLE OF bapiparex,ls_extensionin TYPE bapiparex.DATA: lt_return TYPE STANDARD TABLE OF bapiret2.
DATA: ls_return TYPE bapiret2.DATA: lv_item TYPE bapi_incinv_create_item-invoice_doc_item."预制发票行号"发票
ls_headerdata-invoice_ind = 'X'. "发票
ls_headerdata-deliv_posting = 'S'. "
ls_headerdata-return_posting = 'H'. "
ls_headerdata-gross_amount = '110.74'. "抬头总金额
ls_headerdata-doc_date = '20230412'. "发票日期
ls_headerdata-pstng_date = '20230412'. "过账日期
ls_headerdata-comp_code = '7000'. "公司
ls_headerdata-item_text = '文本'. "文本
ls_headerdata-currency = 'CNY'."货币"税
ls_taxdata-tax_amount = '12.74'. "总税额
ls_taxdata-tax_code = 'J2'."税码
APPEND ls_taxdata TO lt_taxdata.
CLEAR ls_taxdata."行项目
CLEAR lv_item.
lv_item = lv_item + 1.
ls_itemdata-invoice_doc_item = lv_item. "
ls_itemdata-po_number = '4500001299'. "采购订单
ls_itemdata-po_item = '00030'. "采购订单行项目
ls_itemdata-ref_doc = '5000001275'. "参考凭证号
ls_itemdata-ref_doc_year = '2023'. "参考凭证号年度
ls_itemdata-ref_doc_it = '1'. "参考凭证号行项目
ls_itemdata-quantity = '1.000'. "数量
ls_itemdata-po_unit = 'ST'. "单位 要记得转化为内置
ls_itemdata-tax_code = 'J2'. "税码
ls_itemdata-item_amount = '98.00'."<ls_bapi>-zwrbtr3. "不含税金额
"ls_itemdata-item_text = <ls_bapi>-xblnr. "行长文本APPEND ls_itemdata TO lt_itemdata.
CLEAR ls_itemdata."贷方凭证--------
* ls_headerdata-invoice_ind = ''. "贷方凭证
* ls_headerdata-deliv_posting = 'H'. "
* ls_headerdata-return_posting = 'H'. "
* ls_headerdata-gross_amount = '110.74'."抬头金额
* ls_taxdata-tax_amount = '12.74'."税额"总账科目的科目金额
* CLEAR LV_ITEM.
* LV_ITEM = LV_ITEM + 1.
* LS_GLACCOUNTDATA-INVOICE_DOC_ITEM = LV_ITEM.
* LS_GLACCOUNTDATA-GL_ACCOUNT = '1404060000'.
* LS_GLACCOUNTDATA-ITEM_AMOUNT = '12'.
* LS_GLACCOUNTDATA-DB_CR_IND = 'H'.
* LS_GLACCOUNTDATA-TAX_CODE = 'J0'.
* LS_GLACCOUNTDATA-COMP_CODE = '7000'.
* APPEND LS_GLACCOUNTDATA TO LT_GLACCOUNTDATA.
* CLEAR LS_GLACCOUNTDATA.CALL FUNCTION 'BAPI_INCOMINGINVOICE_PARK'EXPORTINGheaderdata = ls_headerdataIMPORTINGinvoicedocnumber = lv_invoicedocnumber "预制发票fiscalyear = lv_fiscalyear "会计年度TABLESitemdata = lt_itemdataglaccountdata = lt_glaccountdatataxdata = lt_taxdatareturn = lt_return.LOOP AT lt_return INTO ls_return WHERE type CA 'EAX'.ENDLOOP.
IF sy-subrc EQ 0.ROLLBACK WORK .
ELSE.WRITE:lv_invoicedocnumber,lv_fiscalyear.COMMIT WORK AND WAIT.
ENDIF.
运行代码:已经产生了预制凭证号
删除预制发票代码:
CALL FUNCTION 'BAPI_INCOMINGINVOICE_DELETE'EXPORTINGinvoicedocnumber = ls_item1-belnr "预制发票fiscalyear = ls_item1-gjahr "年度TABLESreturn = lt_return.LOOP AT lt_return INTO ls_return WHERE type CA 'EAX'.ENDLOOP.IF sy-subrc EQ 0.ROLLBACK WORK .ELSE.COMMIT WORK AND WAIT.ENDIF.
其中我有遇到个错误:
1.你不能处理关于交货成本的条件。
它的解决方法就是行项目不要传供应商(ls_itemdata-FREIGHT_VEN = ‘’)。
供应商应该放在抬头的发票方:ls_headerdata-diff_inv = ‘供应商代码’.
2.[M8429输入有效收货的参考] 与 [00126请仅指定正值] 问题的解决方案
把冲销和被冲销的凭证去掉,不要进入BAPI的行
取数逻辑 :
AND matdoc~cancelled NE ‘X’
AND matdoc~smbln = ‘’
至于做贷方凭证,就是往LT_GLACCOUNTDATA里面赋值就好了。多尝试一下就可以了。
好了今天的分享到这。
分享使我快乐,我是寒武清风。
这篇关于ABAP 创建/删除预制发票,贷方凭证(MIR7)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!