如果SO金额超出指定金额,需要审批,通过标准的配置实现SO的审批功能,然后通过增强检查so的金额,控制是否需要审批。
MV45AFZZ - FORM USEREXIT_READ_DOCUMENT
FORM USEREXIT_READ_DOCUMENT.
* { INSERT
data: lv_netwr TYPE vbak-netwr,
lv_total type p DECIMALS 2 VALUE ‘50000.00’.
IF vbak-waerk NE ‘CNY’.
DATA:lw_return TYPE bapiret1,
lw_rate TYPE bapi1093_0.
CALL FUNCTION ‘BAPI_EXCHANGERATE_GETDETAIL’
EXPORTING
rate_type = ‘M’
from_curr = vbak-waerk
to_currncy = ‘CNY’
date = sy-datum
IMPORTING
exch_rate = lw_rate
return = lw_return.
IF lw_rate-from_factor <> 0.
lv_netwr = vbak-netwr * lw_rate-exch_rate / lw_rate-from_factor.
ELSE.
lv_netwr = vbak-netwr * lw_rate-exch_rate.
ENDIF.
ELSE.
lv_netwr = vbak-netwr.
ENDIF.
" if lv_netwr lt 50000. " 这里不能比较,达不到预期结果,定义一个变量,赋值50000.00,与netwr相同类型 p(8) decimals 2.
if lv_netwr lt lv_total
data: l_objnr type vbak-objnr,
l_objnr2 type vbak-objnr.
"select single objnr into l_objnr from vbak where vbeln = vbak-vbeln.
l_objnr = ‘VB’ && vbak-vbeln && ‘000000’.
select single objnr into l_objnr2 from jest where objnr = l_objnr and stat = ‘E0002’.
if l_objnr2 = ‘’.
CALL FUNCTION ‘I_CHANGE_STATUS’
EXPORTING
objnr = l_objnr
estat_inactive = ‘E0001’
estat_active = ‘E0002’
STSMA = ‘SO_1’
EXCEPTIONS
CANNOT_UPDATE = 1
OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
endif.
endif.
*} INSERT
ENDFORM.