FICO憑證增強之儲存前的修改
SAP對財務憑證的儲存前修改,基本以功能顧問配置替代為主,一般在BADI和出口裡無法實現(這些主要是做條件檢查用)
鑑於第四代增強技術的來襲,為我們提供了一個不是辦法的辦法,在憑證的Update FM(POST_DOCUMENT)裡面打上增強點。
例項1:MRKO--寄售和管道結算的憑證增強,寄售業務的過賬會生成財務憑證。此例比較特殊,經除錯發現有一個現成的出口可用來修改憑證:
RMVKON00(EXIT_RMVKON00_001)
data: lv_varname type zxa_varname,
lv_value type zxa_value1,
lv_subrc like sy-subrc,
lv_index like sy-tabix.
lv_varname = 'DNMC_COMP_CODE'.
loopat t_bkpf.
lv_index = sy-tabix.
lv_value = t_bkpf-bukrs.
callfunction'Z_06XA_CHECK_VALUES'
exporting
iv_varname = lv_varname
iv_value1 = lv_value
importing
ev_subrc = lv_subrc.
if lv_subrc = 0.
t_bkpf-xblnr = '寄售庫存消耗結算'. "不需要翻譯
t_bkpf-bktxt =
modify t_bkpf index lv_index transporting xblnr bktxt.
endif.
endloop.
loopat t_bseg.
lv_index = sy-tabix.
lv_value = t_bseg-bukrs.
callfunction'Z_06XA_CHECK_VALUES'
exporting
iv_varname = lv_varname
iv_value1 = lv_value
importing
ev_subrc = lv_subrc.
if lv_subrc = 0.
"begin of change by pcitycl on 2011-05-19
t_bseg-gsber = '2000'. "寄售結算會計憑證,憑證行專案自動分配業務範圍
modify t_bseg index lv_index transporting gsber.
"begin of change by pcitycl on 2011-05-19
if t_bseg-lifnr isnotinitial.
t_bseg-bvtyp = '0001'.
modify t_bseg index lv_index transporting bvtyp.
endif.
endif.
endloop.
例項2:MIRO--發票校驗的自動過賬,要求根據特定規則填充業務範圍(BSEG-GSBER)
此需求如果採用替代,需要一個完全憑證型別,但此型別卻恰恰對MIRO失效,無奈之下只好採用增強點技術:在POST_DOCUMENT的開始處加程式碼:
"DNMC發票校驗自動分配業務範圍
if sy-tcode = 'MIRO'.
data: ls_setleaf like setleaf,
lt_setleaf liketableof ls_setleaf,
lv_gsber like bseg-gsber,
lv_index1 like sy-tabix.
ranges: lr_set1 for bseg-hkont,
lr_set2 for bseg-hkont.
select * intotable lt_setleaf from setleaf
where setclass = '0000'
and setname = 'Z06ACC0159'. "GR/IR科目集合
loopat lt_setleaf into ls_setleaf.
lr_set1-sign = ls_setleaf-valsign.
lr_set1-option = ls_setleaf-valoption.
lr_set1-low = ls_setleaf-valfrom.
lr_set1-high = ls_setleaf-valto.
append lr_set1.
endloop.
clear lt_setleaf.
select * intotable lt_setleaf from setleaf
where setclass = '0000'
and setname = 'Z06TAX0159'. "稅收科目集
loopat lt_setleaf into ls_setleaf.
lr_set2-sign = ls_setleaf-valsign.
lr_set2-option = ls_setleaf-valoption.
lr_set2-low = ls_setleaf-valfrom.
lr_set2-high = ls_setleaf-valto.
append lr_set2.
endloop.
loopat t_bkpf.
lv_value = t_bkpf-bukrs.
callfunction'Z_06XA_CHECK_VALUES'
exporting
iv_varname = lv_varname
iv_value1 = lv_value
importing
ev_subrc = lv_subrc.
check lv_subrc = 0.
clear lv_gsber.
loopat t_bseg where bukrs = t_bkpf-bukrs
and belnr = t_bkpf-belnr
and gjahr = t_bkpf-gjahr
and hkont in lr_set1.
lv_gsber = t_bseg-gsber.
exit.
endloop.
if lv_gsber isnotinitial.
"用行的科目為GR/IR的業務範圍填充科目為稅收的行
loopat t_bseg where bukrs = t_bkpf-bukrs
and belnr = t_bkpf-belnr
and gjahr = t_bkpf-gjahr
and hkont in lr_set2.
lv_index1 = sy-tabix.
t_bseg-gsber = lv_gsber.
modify t_bseg index lv_index1 transporting gsber.
endloop.
endif.
endloop.
endif.