Today, We will learn SAP BADi MRM_HEADER_CHECK for tcode MIR7 enhancement Park Invoice.
The enhancement purpose is to keep the exchange rate the same with the DN.
Enhancement Place:
se19 Badi MRM_HEADER_CHECK.
When to trigger the enhancement point:
Press the save buttoon in MIR7.
How to do this?
- Se19 create a BADI for MRM_HEADER_CHECK
- Write below SAP ABAP source code in method HEADERDATA_CHECK
=======================================
=======================================
CHECK( sy-ucomm = ‘PARK’ OR ( sy-ucomm = ” AND g_error = ‘X’ ) ) AND sy-tcode = ‘MIR7’ AND i_rbkpv-bukrs = ‘HOT583’ .
DATA:
l_lines LIKE sy-tabix,
l_index LIKE sy-tabix,
ls_drseg LIKE LINE OF ti_drseg,
lt_drseg TYPE mmcr_tdrseg,
lt_ekbe TYPE TABLE OF ekbe,
ls_bkpf TYPE bkpf,
lt_bkpf TYPE TABLE OF bkpf.
FIELD-SYMBOLS:<fs_bkpf> LIKE LINE OF lt_bkpf.
LOOP AT ti_drseg INTO ls_drseg WHERE selkz = ‘X’ .
*读取对应的采购订单行,是否有预制凭证
SELECT ebeln
ebelp
xblnr
FROM ekbe
INTO CORRESPONDING FIELDS OF TABLE lt_ekbe
WHERE ebeln = ls_drseg-ebeln
AND ebelp = ls_drseg-ebelp
AND xblnr = ls_drseg-xblnr
AND vgabe IN (‘P’,’2′)
AND bewtp IN (‘T’,’Q’).
IF sy-subrc = 0.
g_error = ‘X’.
MESSAGE e066(WWW.HOT583.COM) WITH ls_drseg-ebeln ls_drseg-ebelp.
ELSE.
CLEAR g_error.
ENDIF.
APPEND ls_drseg TO lt_drseg.
ENDLOOP.
*找相同交货单会计凭证
IF lt_drseg[] IS NOT INITIAL.
SELECT *
FROM bkpf
INTO TABLE lt_bkpf
FOR ALL ENTRIES IN lt_drseg
WHERE bukrs = lt_drseg-bukrs
AND gjahr = lt_drseg-gjahr
AND xblnr = lt_drseg-xblnr.
“如果是CNY 汇率默认为1
LOOP AT lt_bkpf ASSIGNING <fs_bkpf> WHERE waers = ‘CNY’.
<fs_bkpf>-kursf = ‘1’.
ENDLOOP.
SORT lt_bkpf BY kursf.
DELETE ADJACENT DUPLICATES FROM lt_bkpf COMPARING kursf.
DESCRIBE TABLE lt_bkpf LINES l_lines.
IF l_lines > 1.
*多张交货单汇率不一致,请检查
MESSAGE e075(WWW.HOT583.COM).
ENDIF.
LOOP AT lt_bkpf INTO ls_bkpf.
IF ls_bkpf-waers <> i_rbkpv-waers.“发票货币与交货单货币不一致
*发票货币与交货单货币不一致
MESSAGE e077(WWW.HOT583.COM) .
ELSEIF ls_bkpf-waers <> ‘CNY’ AND ls_bkpf-kursf <> i_rbkpv-kursf.“如果是外币,判断汇率是否一直
*发票汇率与会计凭证&中交货单汇率不一致,请检查
MESSAGE e076(WWW.HOT583.COM) WITH ls_bkpf-belnr .
ENDIF.
ENDLOOP.
ENDIF.
我的微信公众号【 hot583 】 或者在这个链接联系我
本文链接 :http://www.hot583.com/2023/01/13/mrm_header_check/
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
微信原文《全文完》