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 ...
随机推荐
- plsql日期乱码
乱码状况如截图: 控制面板\所有控制面板项\系统\高级系统设置\环境变量, 设置系统变量,变量名:NLS_LANG,变量值:Simplified Chinese_China.AL32UTF8改为SIM ...
- XCode5 真机调试及发布应用
一.XCODE 真机测试 Xcode5已经很智能,只需生成一个开发证书,安装后,插入设备会自动添加,注意,当Mac系统升级后,证书需要重新生成. 证书生成步骤: 1.生成 CertificateSig ...
- Web前端工作2个月小结
开始语: 2013年6月30日,Microsoft Learning support 项目结束,转而进入Forerunner Development 项目,这对于这块领域空白的我,空前的困难,可是我坚 ...
- C#:简单线程样例
1.定义线程类及内部事件 using System; using System.Collections.Generic; using System.Text; using System.Threadi ...
- java final .static修饰符
static静态修饰符(使用static修饰符修饰的成员变量.常量.和成员方法成为静态变量.常量和方法,他们统称为静态成员,归整个类所有,不依赖于类的特定实例,被类的所有实例共享,只要这个类被加载,J ...
- [ios][swift]swift 怎么去除 optional
在转换String时要使用“!”进行拆包,用“?”则会有optional 出现
- 发现数据库错误模式(AppScan扫描结果)
最近工作要求解决下web的项目的漏洞问题,扫描漏洞是用的AppScan工具,其中此篇文章是关于发现数据库错误模式问题的.下面就把这块东西分享出来. 原创文章,转载请注明 --------------- ...
- 算法大全(c,c++)
http://www.2cto.com/kf/201109/105758.html 算法大全(C,C++)一. 数论算法 1.求两数的最大公约数function gcd(a,b:integer):in ...
- python Flask restful框架
框架地址:https://github.com/flask-restful/flask-restful 文档:http://flask-restful.readthedocs.io/en/0.3.5/ ...
- 局部内部类访问方法中的局部变量为什么加final
转载:http://www.cnblogs.com/mjblogs/p/4971630.html 1)从程序设计语言的理论上:局部内部类(即:定义在方法中的内部类),由于本身就是在方法内部(可出现在形 ...