BADI名:BADI_MATERIAL_CHECK
首先在SE19下实例化BADI
进入实施类中找到对应的方法,本文中的增强是针对维护会计视图时的数据检查,启用方法:CHECK_DATA,其可用参数如下
进入CHECK_DATA的实现中,编写代码即可:
代码文本:
IF WMBEW-BKLAS IS NOT INITIAL .
DATA GV_MARC TYPE MARC .
IF WMARC-WERKS = '1202'.
CLEAR GV_MARC .
SELECT SINGLE * INTO CORRESPONDING FIELDS OF GV_MARC FROM MARC
WHERE WERKS = '1202'
AND PSTAT = 'D'
AND MATNR = WMARC-MATNR
.
IF SY-SUBRC = 0.
IF GV_MARC-SOBSL = 99.
IF WMBEW-STPRS <> 0 OR WMBEW-VERPR <> 0.
MESSAGE '请清空价格后再保存!' TYPE 'E' .
ENDIF.
ENDIF.
ELSE.
IF WMARC-BESKZ IS NOT INITIAL.
IF WMARC-SOBSL = 99..
IF WMBEW-STPRS <> 0 OR WMBEW-VERPR <> 0.
MESSAGE '请清空价格后再保存!' TYPE 'E' .
ENDIF.
ENDIF.
ELSE .
MESSAGE '请先创建MRP视图!' TYPE 'E' .
ENDIF.
ENDIF.
ENDIF.
ENDIF.