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'.
loop at t_bkpf.
lv_index = sy-tabix.
lv_value = t_bkpf-bukrs.
call function '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.
loop at t_bseg.
lv_index = sy-tabix.
lv_value = t_bseg-bukrs.
call function '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 is not initial.
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 like table of ls_setleaf,
lv_gsber like bseg-gsber,
lv_index1 like sy-tabix.
ranges: lr_set1 for bseg-hkont,
lr_set2 for bseg-hkont.
select * into table lt_setleaf from setleaf
where setclass = '0000'
and setname = 'Z06ACC0159'. "GR/IR科目集合
loop at 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 * into table lt_setleaf from setleaf
where setclass = '0000'
and setname = 'Z06TAX0159'. "税收科目集
loop at 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.
loop at t_bkpf.
lv_value = t_bkpf-bukrs.
call function '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.
loop at 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 is not initial.
"用行的科目为GR/IR的业务范围填充科目为税收的行
loop at 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.