MIRO发票校验BAPI_INCOMINGINVOICE_CREATE (2013-01-23 10:01:29)
form frm_invoice_create2 .
data: str type string.
data: ls_headerdata like bapi_incinv_create_header,
lt_itemdata like table of bapi_incinv_create_item,
ls_itemdata like bapi_incinv_create_item,
lt_return like table of bapiret2,
ls_return like bapiret2,
lv_invoicedocnumber like bapi_incinv_fld-inv_doc_no,
lv_fiscalyear like bapi_incinv_fld-fisc_year.
data: lv_price1 type bapi_rmwwr.
data: lv_item type n length 6.
data: lv_retpo type retpo.
clear:l_menge,ls_headerdata,lv_fiscalyear,lv_price1,lv_item.
* 处理退货和非退货项目
clear: gt_ret,gt_ret[],gt_inv,gt_inv[].
loop at gt_alv into gs_alv where source = 'EKBE'.
clear: lv_retpo.
select single retpo into lv_retpo from ekpo where ebeln = gs_alv-ebeln and ebelp = gs_alv-ebelp.
loop at gt_invoice into gs_invoice where ebeln = gs_alv-ebeln and ebelp = gs_alv-ebelp.
*---------根据退货标识 放入不同的内表
if lv_retpo = 'X'."退货项目
if gs_invoice-shkzg = 'H'.
gs_invoice-dmbtr = 0 - gs_invoice-dmbtr.
endif.
gt_ret-ebeln = gs_invoice-ebeln."采购订单
gt_ret-ebelp = gs_invoice-ebelp."行项目
gt_ret-lfbnr = gs_invoice-lfbnr. "参考凭证号
gt_ret-lfpos = gs_invoice-lfpos."行项目
gt_ret-lfgja = gs_invoice-lfgja."年度
gt_ret-mwskz = gs_invoice-mwskz."税码
gt_ret-dmbtr = gs_invoice-dmbtr. "金额
gt_ret-menge = gs_invoice-menge. "数量
select single meins into gt_ret-meins from ekpo where ebeln = gs_invoice-ebeln and ebelp = gs_invoice-ebelp.
collect gt_ret.
else.
if gs_invoice-shkzg = 'H'.
gs_invoice-dmbtr = 0 - gs_invoice-dmbtr.
endif.
gt_inv-ebeln = gs_invoice-ebeln."采购订单
gt_inv-ebelp = gs_invoice-ebelp."行项目
gt_inv-lfbnr = gs_invoice-lfbnr. "参考凭证号
gt_inv-lfpos = gs_invoice-lfpos."行项目
gt_inv-lfgja = gs_invoice-lfgja."年度
gt_inv-mwskz = gs_invoice-mwskz."税码
gt_inv-dmbtr = gs_invoice-dmbtr. "金额
gt_inv-menge = gs_invoice-menge. "数量
select single meins into gt_inv-meins from ekpo where ebeln = gs_invoice-ebeln and ebelp = gs_invoice-ebelp.
collect gt_inv.
endif.
endloop.
endloop.
*---正常订单发票校验
clear: ls_headerdata.
ls_headerdata-invoice_ind = 'X'. "当采购订单行项目是正常订单时该标识必为X,为miro界面上的业务处理为1.发票否则为2.贷方凭证(invoice_ind='X'表示miro界面最上部的业务处理是1.发票,invoice_ind='', 表示miro界面最上部的业务处理为2.贷方凭证)
ls_headerdata-doc_type = 'YX'.
ls_headerdata-doc_date = p_datum.
ls_headerdata-pstng_date = g_post_date.
ls_headerdata-bline_date = g_post_date. "基线日期/付款计算的起始日期
ls_headerdata-comp_code = p_bukr2.
ls_headerdata-currency = 'CNY'.
ls_headerdata-calc_tax_ind = 'X'. "自动结算税额
ls_headerdata-bus_area = '9999'.
clear: lv_item.
loop at gt_inv.
lv_item = lv_item + 1. "发票行项目号
ls_itemdata-invoice_doc_item = lv_item.
ls_itemdata-po_number = gt_inv-ebeln.
ls_itemdata-po_item = gt_inv-ebelp.
ls_itemdata-ref_doc = gt_inv-lfbnr.
ls_itemdata-ref_doc_year = gt_inv-lfgja.
ls_itemdata-ref_doc_it = gt_inv-lfpos.
ls_itemdata-item_amount = gt_inv-dmbtr.
ls_itemdata-quantity = gt_inv-menge.
ls_itemdata-po_unit = gt_inv-meins.
if gt_ret-mwskz is not initial.
ls_itemdata-tax_code = gt_inv-mwskz.
else.
ls_itemdata-tax_code = p_mwskz.
endif.
append ls_itemdata to lt_itemdata.
clear: ls_itemdata.
lv_price1 = lv_price1 + abs( gt_inv-dmbtr ).
endloop.
ls_headerdata-gross_amount = lv_price1 * ( 100 + l_mwskz ) / 100. "总金额
refresh: lt_return.clear: ls_return,invoicedocnumber.
call function 'BAPI_INCOMINGINVOICE_CREATE'
exporting
headerdata = ls_headerdata
importing
invoicedocnumber = invoicedocnumber
tables
itemdata = lt_itemdata
return = lt_return.
loop at lt_return into ls_return where type = 'E' or type = 'A'.
cp_eind = 'X'.
exit.
endloop.
if cp_eind ne 'X'.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
*---插入值到表ZTFI014
gs_ztfi014-tcode = sy-tcode.
gs_ztfi014-seqno = p_datum.
gs_ztfi014-objnr = p_bukr2.
gs_ztfi014-gjahr = p_datum(4).
gs_ztfi014-bukrs = p_bukrs.
gs_ztfi014-belnr = invoicedocnumber.
modify ztfi014 from gs_ztfi014.
else.
call function 'BAPI_TRANSACTION_ROLLBACK'.
loop at lt_return into ls_return.
clear gs_log.
gs_log-type = ls_return-type.
gs_log-docno = invoicedocnumber.
call function 'MESSAGE_TEXT_BUILD'
exporting
msgid = ls_return-id
msgnr = ls_return-number
msgv1 = ls_return-message_v1
msgv2 = ls_return-message_v2
msgv3 = ls_return-message_v3
msgv4 = ls_return-message_v4
importing
message_text_output = gs_log-message.
case gs_log-type.
when 'S'.
gs_log-icon = '3'.
when 'W'.
gs_log-icon = '2'.
when 'E' or 'A'.
gs_log-icon = '1'.
when others.
endcase.
append gs_log to gt_log.
clear ls_return.
endloop.
message e001(00) with '第一张发票预制失败,请点击显示消息查看详情!'.
endif.
*---退货订单发票校验
clear: ls_headerdata-invoice_ind,ls_headerdata-gross_amount. "发票标志 退货是该标识必须为空
clear: lv_item,ls_itemdata,ls_return,invoicedocnumber,lv_price1.
refresh: lt_itemdata,lt_return.
loop at gt_ret.
lv_item = lv_item + 1. "发票行项目号
ls_itemdata-invoice_doc_item = lv_item.
ls_itemdata-po_number = gt_ret-ebeln.
ls_itemdata-po_item = gt_ret-ebelp.
ls_itemdata-ref_doc = gt_ret-lfbnr.
ls_itemdata-ref_doc_year = gt_ret-lfgja.
ls_itemdata-ref_doc_it = gt_ret-lfpos.
ls_itemdata-item_amount = abs( gt_ret-dmbtr ).
ls_itemdata-quantity = gt_ret-menge.
ls_itemdata-po_unit = gt_ret-meins.
if gt_inv-mwskz is not initial.
ls_itemdata-tax_code = gt_ret-mwskz.
else.
ls_itemdata-tax_code = p_mwskz.
endif.
append ls_itemdata to lt_itemdata.
clear: ls_itemdata.
lv_price1 = lv_price1 + abs( gt_ret-dmbtr ).
endloop.
ls_headerdata-gross_amount = lv_price1 * ( 100 + l_mwskz ) / 100. "总金额
refresh: lt_return.clear: ls_return.
call function 'BAPI_INCOMINGINVOICE_CREATE'
exporting
headerdata = ls_headerdata
importing
invoicedocnumber = invoicedocnumber
tables
itemdata = lt_itemdata
return = lt_return.
loop at lt_return into ls_return where type = 'E' or type = 'A'.
cp_eind = 'X'.
exit.
endloop.
if cp_eind ne 'X'.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
*---插入值到表ZTFI014
gs_ztfi014-tcode = sy-tcode.
gs_ztfi014-seqno = p_datum.
gs_ztfi014-objnr = p_bukr2.
gs_ztfi014-gjahr = p_datum(4).
gs_ztfi014-bukrs = p_bukrs.
gs_ztfi014-belnr = invoicedocnumber.
modify ztfi014 from gs_ztfi014.
else.
call function 'BAPI_TRANSACTION_ROLLBACK'.
loop at lt_return into ls_return.
clear gs_log.
gs_log-type = ls_return-type.
gs_log-docno = invoicedocnumber.
call function 'MESSAGE_TEXT_BUILD'
exporting
msgid = ls_return-id
msgnr = ls_return-number
msgv1 = ls_return-message_v1
msgv2 = ls_return-message_v2
msgv3 = ls_return-message_v3
msgv4 = ls_return-message_v4
importing
message_text_output = gs_log-message.
case gs_log-type.
when 'S'.
gs_log-icon = '3'.
when 'W'.
gs_log-icon = '2'.
when 'E' or 'A'.
gs_log-icon = '1'.
when others.
endcase.
append gs_log to gt_log.
clear ls_return.
endloop.
message e001(00) with '第二张发票预制失败,请点击显示消息查看详情!'.
endif.
endform. " FRM_INVOICE_CREATE2
注意:
在PO收货后,做发票校验,发现一个问题,就是在headerdata中有个参数 calc_tax_ind ,如果将这个值‘X’,那么在
ME23N中会看不到生成的发票校验凭证invoicedocnumber的值。
headerdata中的必输值:
invoice_ind 为'X'
doc_date
pstng_date
comp_code
currency
gross_amount
itemdata中的必输值:
invoice_doc_item
po_number
po_item
item_amount
quantity
po_unit
ref_doc
ref_doc_year
ref_doc_it
MIRO发票校验BAPI_INCOMINGINVOICE_CREATE (2013-01-23 10:01:29)的更多相关文章
- 002 MIRO发票校验采购订单项目科目分配类别检查增强-20150819
BADI SE19:ZINVOICE_UPDATE MIRO发票检验过账好模拟时,检查采购订单line 是否有固定资产的行项目,如果有固定资产项目,则弹出提示框,提示消息:存在规定资产采购项目! ...
- MM--发票校验 及基于采购订单的MIRO发票校验过程(
一.介绍发票校验是物料管理(MM)系统的一部分.它提供物料管理部分和财务会计, 成本控制和资产管理部分的连接.物料管理模块的发票校验为以下目的服务:它完成物料采购的全过程 - 物料采购从采购申请开始, ...
- 发票校验BAPI_INCOMINGINVOICE_CREATE
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE' EXPORTING headerdata = headerdata ...
- 小白的python之路Linux部分10/28&29
属主属组其他人对文件的rwx权限 1.userdel删东西不全,会有残留,
- MIRO做发票校验时实现替代功能的多种方式
http://blog.sina.com.cn/s/blog_3f2c03e30100ngje.html MIRO做发票校验时,如果需要对产生的会计凭证做某些字段的替代,可有多种方法. 1.GGB1替 ...
- SAP研究贴之--发票校验提示移动平均价为负
近日,应付岗密集出现发票校验时移动平均价为负值导致过账失败的情况,采购经理又是拍桌子.又是摔杯子的.财务经理安排任务彻底清查,找出问题原因.哎,毫无头绪啊...测试机模拟业务吧流程:合同(系统外)-采 ...
- http://www.cnblogs.com/peida/archive/2013/04/23/3036035.html
http://www.cnblogs.com/peida/archive/2013/04/23/3036035.html
- VRay 2.0 SP1 2.10.01 for 3ds max 9/2008/2009/2010/2011/2012 32/64位 顶渲简体中文版+英文版[中国室内设计论坛-室内人]
VRay 2.0 SP1 2.10.01 for 3ds max 9/2008/2009/2010/2011/2012 32/64位 顶渲简体中文版+英文版[中国室内设计论坛-室内人] 对最新版本的V ...
- Redis的sentinel机制(sentinel节点IP为:192.168.23.10) “哨兵”
万一主节点打击,主从模型将会停止工作,为了解决这个问题,Redis提供了一个sentinel(哨兵),以此来实现主从切换的功能,一旦主节点宕机了,sentinel将会在从节点中挑一个作为主节点.与zo ...
随机推荐
- 【jqGrid for ASP.NET MVC Documentation】.学习笔记.2.jqGrid Model-View-Controller 分离
1 基本 分离代码 和 描述 ,在ASP.NET MVC 应用程序中是非常重要的.因此,jqGrid 的 mvc 模式使用一个共同的网格安装设置,包括 Model ,Controller 和 View ...
- Codeforces 745C:Hongcow Builds A Nation(并查集)
http://codeforces.com/problemset/problem/744/A 题意:在一个图里面有n个点m条边,还有k个点是受限制的,即不能从一个受限制的点走到另外一个受限制的点(有路 ...
- C++ Template Operator
#include <iostream> #include <string> #include <deque> #include <stdexcept> ...
- 2016年省赛G题, Parenthesis
Problem G: Parenthesis Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 398 Solved: 75[Submit][Status ...
- HDU 4810 Wall Painting
Wall Painting Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 2016年11月19日 星期六 --出埃及记 Exodus 20:10
2016年11月19日 星期六 --出埃及记 Exodus 20:10 but the seventh day is a Sabbath to the LORD your God. On it you ...
- C# for和 foreach 的数组遍历 比较
刚学习程序,感觉写代码 很有意思,所以把自己的感悟写下来啦,第一次写博客,可能是菜鸟中的菜鸟 时间久了,相信就会写的很好哦! for和 foreach 的数组遍历 比较 很简单的程序,不解释啦! u ...
- GCD之dispatch queue深入浅出
GCD之dispatch queue深入浅出 http://blog.csdn.net/samuelltk/article/details/9452203
- ViewController之间的切换动画
一 .API介绍 iOS7开始,苹果推出了自定义转场动画API.从此,任何可以用Core Animation实现的动画,都可以出现在两个ViewController的切换之间 知识点图: 从上图可以看 ...
- centos6.5 ssh安全优化,修改默认端口名,禁止root远程登录
一.修改默认端口号 第一步: vi /etc/sysconfig/iptables 添加修改后的端口号的配置 -A INPUT -p tcp -m state --state NEW -m tcp - ...