1. 业务处理(transaction)字段选择:
创建后续借记(subsequent debit)
ItemData DE_CRE_IND = 'X'
HeaderData INVOICE_IND = 'X'
创建后续贷记(subsequent credit)
ItemData DE_CRE_IND = 'X'
HeaderData INVOICE_IND = ' '
发票(invoice)
HeaderData INVOICE_IND = 'X'
贷方凭证(credit demo)
HeaderData INVOICE_IND = ' '
2. 标识: 货物项目/交货成本/全部(Indicator: Goods Items/Delivery Costs/Both)
货物/服务项目(Goods/service items)
ItemData COND_TYPE = ' '
COND_ST_NO = ' '
COND_COUNT = ' '
计划交货成本(Planned delivery costs)
ItemData COND_TYPE = 'X'
COND_ST_NO = 'X'
COND_COUNT = 'X'
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的更多相关文章
-
swap函数的四种写法
swap 函数的四种写法 (1)经典型 --- 嫁衣法 void swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } ( ...
-
C语言中返回字符串函数的四种实现方法 2015-05-17 15:00 23人阅读 评论(0) 收藏
C语言中返回字符串函数的四种实现方法 分类: UNIX/LINUX C/C++ 2010-12-29 02:54 11954人阅读 评论(1) 收藏 举报 语言func存储 有四种方式: 1.使用堆空 ...
-
JavaScript高级之函数的四种调用形式
主要内容 分析函数的四种调用形式 弄清楚函数中this的意义 明确构造函对象的过程 学会使用上下文调用函数 了解函数的调用过程有助于深入学习与分析JavaScript代码. 本文是JavaScript ...
-
C语言中返回字符串函数的四种实现方法
转自C语言中返回字符串函数的四种实现方法 其实就是要返回一个有效的指针,尾部变量退出后就无效了. 有四种方式: 1.使用堆空间,返回申请的堆地址,注意释放 2.函数参数传递指针,返回该指针 3.返回函 ...
-
JavaScript函数的四种存在形态
函数的四种存在形态: 1.函数形态 2.方法形态 将函数赋值给某一个对象的成员,那么就称为方法 3.构造器形态 4.上下文形态 1.函数形态: var foo = function() { ale ...
-
JS高级. 06 缓存、分析解决递归斐波那契数列、jQuery缓存、沙箱、函数的四种调用方式、call和apply修改函数调用方法
缓存 cache 作用就是将一些常用的数据存储起来 提升性能 cdn //-----------------分析解决递归斐波那契数列<script> //定义一个缓存数组,存储已经计算出来 ...
-
JS面向对象函数的四种调用模式
函数的四种调用模式 概念 在 js 中,无论是函数, 还是方法, 还是事件, 还是构造器,...这些东西的本质都是函数 函数, 方法, 事件, 构造器,...只是所处的位置不同 这四种模式分别是 函数 ...
-
函数的四种调用模式.上下文调用.call.apply
闭包:函数就是一个闭包,一个封闭的作用域; 返回函数,要返回多个函数就用一个对象封装一下, 立即执行函数+return 回调函数 JS动态创建的DOM,不会被搜索引 ...
-
MIRO发票校验BAPI_INCOMINGINVOICE_CREATE (2013-01-23 10:01:29)
form frm_invoice_create2 . data: str type string. data: ls_headerdata like bapi_incinv_creat ...
随机推荐
-
codeforces C. Vasily the Bear and Sequence 解题报告
题目链接:http://codeforces.com/problemset/problem/336/C 题目意思:给出一个递增的正整数序列 a1, a2, ..., an,要求从中选出一堆数b1, b ...
-
ADO.NET+Access: 1,标准表达式中数据类型不匹配
ylbtech-Error-ADO.NET+Access: 1,标准表达式中数据类型不匹配. 1.A,错误代码返回顶部 1,标准表达式中数据类型不匹配. 1.B,出错原因分析返回顶部 未解决 1. ...
-
ML 徒手系列 拉格朗日乘子法
拉格朗日乘子法是解决极值问题的方法. 本方法是计算多元函数在约束条件下的极值问题的方法. 1.多元函数与约束问题 如下图所示,f(x,y)为多元函数,g(x,y)=c为约束条件.目的是计算在约束条件下 ...
-
使用WITH AS 的ROW_NUMBER分页
WITH tempTable AS( --复杂查询语句) SELECT * FROM (select ROW_NUMBER() Over( order by xxx) as rowNum, ...
-
poj 2226 Muddy Fields(最小点覆盖+巧妙构图)
Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= ...
-
NOTIC: Invalid argument supplied for foreach()
NOTIC: [2] Invalid argument supplied for foreach() Warning: Invalid argument supplied for foreach() ...
-
hdu 2097 sky数(进制转换)
Sky数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
-
【BZOJ5306】 [Haoi2018]染色
BZOJ5306 [Haoi2018]染色 Solution xzz的博客 代码实现 #include<stdio.h> #include<stdlib.h> #include ...
-
20155232《网络对抗》Exp5 MSF基础应用
20155232<网络对抗>Exp5 MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode. exploit:就是利用可能存在的漏洞对目标进行攻击 ...
-
mvn jetty debug
使用mvn jetty:run很爽吧,但是怎么debug了,找了Google的N多老外文章,终于可以了,文章链接:http://gaertig.pl/blog/en/2009/03/debug-jet ...