其他分享
首页 > 其他分享> > ABAP-MB21,MB22保存校验

ABAP-MB21,MB22保存校验

作者:互联网

如果想检查单行的话可以通过BADI:MB_RESERVATION_BADI,本文是检查重复物料,所以不好使用这个BADI,用了隐式增强

隐式增强位置,程序:MM07RFD0

 

 

 1   TYPES:
 2     BEGIN OF TY_MATNR,
 3       MATNR TYPE MARA-MATNR,
 4     END OF TY_MATNR.
 5 
 6   DATA:
 7     LS_MATNR  TYPE TY_MATNR,
 8     LT_MATNR  TYPE TABLE OF TY_MATNR.
 9 
10   IF FCODE_NEXT = FCOD-BU.
11     IF SY-TCODE = 'MB21'
12     OR SY-TCODE = 'MB22'.
13       LOOP AT YRSEG
14         WHERE XLOEK <> 'X'.
15         READ TABLE LT_MATNR TRANSPORTING NO FIELDS
16           WITH KEY MATNR = YRSEG-MATNR.
17 
18         IF SY-SUBRC <> 0.
19           LS_MATNR-MATNR = YRSEG-MATNR.
20           APPEND LS_MATNR TO LT_MATNR.
21         ELSE.
22           MESSAGE '物料' && YRSEG-MATNR && '有重复项!' TYPE 'E'.
23         ENDIF.
24       ENDLOOP.
25     ENDIF.
26   ENDIF.

 

标签:MB22,MB21,MATNR,YRSEG,TY,LT,ABAP,LS,TYPE
来源: https://www.cnblogs.com/liangliang245916893/p/14109898.html