1.MIGO前台增强:
1.SE18找到增强点:MB_GOODSMOVEMENT
2.找到相应的BADI:右键创建实施
3.找到重写的方法
METHOD if_ex_mb_document_badi~mb_document_before_update.
DATA:lv_stat TYPE c,
lv_type TYPE bapi_mtype,
lv_msg TYPE bapi_msg.
DATA:lv_message TYPE string.
IF sy-tcode = 'MIGO'.
LOOP AT xmseg ASSIGNING FIELD-SYMBOL(<lfs_mseg>).
CALL FUNCTION 'ZMM_STATEMENT_SRM'
EXPORTING
mblnr = <lfs_mseg>-mblnr
gjahr = <lfs_mseg>-gjahr
zeile = <lfs_mseg>-zeile
IMPORTING
ev_stat = lv_stat
ev_type = lv_type
ev_msg = lv_msg.
IF lv_stat = 1.
lv_message = '物料凭证' && <lfs_mseg>-mblnr && '行项目' && <lfs_mseg>-zeile && '已对账不允许原单退货,请通过采购退货订单退货!' .
MESSAGE lv_message TYPE 'E'.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
2.MIGO 三代增强(BAPI会走这里,上面的那个增强BAPI不会走):
1.SE19:创建BADI实施:
METHOD if_ex_mb_migo_badi~post_document.
DATA:lv_message TYPE string.
FIELD-SYMBOLS: <lfs_objnr_all> TYPE ANY TABLE.
DATA lt_ripw0_t TYPE STANDARD TABLE OF ripw0 WITH NON-UNIQUE SORTED KEY uii COMPONENTS uii.
ASSIGN ('(SAPLIPW1)XOBJK_ALL[]') TO <lfs_objnr_all>.
IF <lfs_objnr_all> IS ASSIGNED.
lt_ripw0_t[] = <lfs_objnr_all>.
ENDIF.
IF lt_ripw0_t[] IS NOT INITIAL.
SELECT
e~equnr,
e~matnr,
e~lbbsa
FROM v_equi_eqbs_sml AS e
FOR ALL ENTRIES IN @lt_ripw0_t
WHERE e~equnr = @lt_ripw0_t-equnr
INTO TABLE @DATA(lt_ser).
LOOP AT it_mseg INTO DATA(is_mseg) WHERE bwart = '344'.
READ TABLE lt_ser INTO DATA(ls_ser) WITH KEY matnr = is_mseg-matnr lbbsa = '07'.
IF sy-subrc = 0.
lv_message = '行项目' && is_mseg-zeile
&& '物料' && ls_ser-matnr
&& '序列号' && ls_ser-equnr && '不能重复冻结库存' .
MESSAGE lv_message TYPE 'E'.
ENDIF.
ENDLOOP.
ENDIF.
DATA: wa_zzsmseg TYPE ztmseg,
lt_zzsmseg TYPE TABLE OF ztmseg,
wa_item TYPE zzsmseg_s,
wa_mseg TYPE mseg.
IF it_item[] IS NOT INITIAL.
LOOP AT it_item INTO wa_item.
READ TABLE it_mseg INTO wa_mseg
WITH KEY line_id = wa_item-line_id.
IF sy-subrc EQ 0.
wa_zzsmseg-mblnr = wa_mseg-mblnr.
wa_zzsmseg-mjahr = wa_mseg-mjahr.
wa_zzsmseg-zeile = wa_mseg-zeile.
wa_zzsmseg-zshdh = wa_item-zshdh.
wa_zzsmseg-zshdh_item = wa_item-zshdh_item.
APPEND wa_zzsmseg TO lt_zzsmseg.
ENDIF.
ENDLOOP.
CALL FUNCTION 'ZFMMM_UPDATE_DATA' IN UPDATE TASK
TABLES
it_item = lt_zzsmseg.
ENDIF.
ENDMETHOD.
3.ITEM检查增强:这里增强没有前台页面行项目数据 需要在自定义类中手动添加,初始化,行更新删除时都需要更新此全局表