1. 先得通过后台spor配置,找到相应的视图,即需要做增强的视图。找到相应的函数组,屏幕号。好了,可以进行编辑屏幕了。
FUNCTION-POOL zmm004 MESSAGE-ID m3.
TABLES: ztmm001.
DATA: w_ztmm004 type ztmm001.
DATA: w_ztmm007 type ztmm001.
DATA: l_matnr TYPE matnr.
*TF 4.6C Materialfixierung=================================
INCLUDE <icon>.
*TF 4.6C Materialfixierung=================================
INCLUDE mmmgtrbb.
INCLUDE mmmgbbau.
*-----------------------------
INCLUDE wstr_definition. "Holds BADI global definition
INCLUDE lmgd1iv0. "IS2ERP
*&---------------------------------------------------------------------*
*& Module DISABLE_FIELD OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE disable_field OUTPUT.
IF sy-tcode = 'MM03'.
LOOP AT SCREEN.
screen-input = '0'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDMODULE. " DISABLE_FIELD OUTPUT
*&---------------------------------------------------------------------*
*& Module GET_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE get_data OUTPUT.
IF sy-tcode = 'MM01' OR sy-tcode = 'MM02' OR sy-tcode = 'MM03'.
GET PARAMETER ID 'MAT' FIELD l_matnr.
IF ztmm001 IS INITIAL.
SELECT SINGLE * FROM ztmm001
WHERE matnr = l_matnr.
ENDIF.
ENDIF.
ENDMODULE. " GET_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module ASSGIN_DATA INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE assgin_data INPUT.
ztmm001-matnr = l_matnr.
w_ztmm004 = ztmm001.
EXPORT w_ztmm004 TO MEMORY ID 'ZTMM004'.
ENDMODULE. " ASSGIN_DATA INPUT
MODULE assgin_data_3 INPUT.
ztmm001-matnr = l_matnr.
w_ztmm007 = ztmm001.
EXPORT w_ztmm007 TO MEMORY ID 'ZTMM007'.
ENDMODULE. " ASSGIN_DATA INPUT
2. 接下来是去在增强点mga00001中实现提交数据库部分。
*&---------------------------------------------------------------------*
*& 包括 ZXMG0U02
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(WMARA) LIKE MARA STRUCTURE MARA
*" VALUE(WMARC) LIKE MARC STRUCTURE MARC
*" VALUE(WMARD) LIKE MARD STRUCTURE MARD
*" VALUE(WMBEW) LIKE MBEW STRUCTURE MBEW
*" VALUE(WMLGN) LIKE MLGN STRUCTURE MLGN
*" VALUE(WMLGT) LIKE MLGT STRUCTURE MLGT
*" VALUE(WMVKE) LIKE MVKE STRUCTURE MVKE
*" VALUE(WSTAT) LIKE MGSTAT STRUCTURE MGSTAT
*" VALUE(WMFHM) LIKE MFHM STRUCTURE MFHM
*" VALUE(WMPOP) LIKE MPOP STRUCTURE MPOP
*" TABLES
*" STEXT STRUCTURE SHORT_DESC
*" SSTEUERTAB STRUCTURE MG03STEUER
*" SSTEUMMTAB STRUCTURE MG03STEUMM
*" WMEINH STRUCTURE SMEINH
*" SMEAN_ME_TAB STRUCTURE MEAN
*" CHANGING
*" VALUE(CMARA) LIKE MARU STRUCTURE MARU
*" EXCEPTIONS
*" APPLICATION_ERROR
*"----------------------------------------------------------------------
TABLES:ztmm001,ztmm002.
DATA: w_ztmm001 TYPE ztmm002,
w_ztmm002 TYPE ztmm001,
w_ztmm003 TYPE ztmm002,
w_ztmm004 TYPE ztmm001,
w_ztmm005 TYPE ztmm002,
w_ztmm006 TYPE ztmm002,
w_ztmm007 TYPE ztmm001.
DATA: lt_ztmm020 TYPE STANDARD TABLE OF ztmm020 WITH HEADER LINE.
DATA: l_maktx TYPE makt-maktx.
*对于物料批次的启用方案定在1100,其他工厂不启用批次,因此在物料主数据层面增强控制1100方可启用,其余工厂不进行启用
IF wmarc-xchpf = 'X'.
IF wmarc-werks = '1100' OR wmarc-werks = '1250'.
ELSE.
MESSAGE '非1100工厂不允许启用批次' TYPE 'E'.
ENDIF.
ENDIF.
IF sy-ucomm = 'BU' OR sy-ucomm = 'YES'.
IMPORT w_ztmm001 FROM MEMORY ID 'ZTMM001'.
IMPORT w_ztmm003 FROM MEMORY ID 'ZTMM003'.
IMPORT w_ztmm002 FROM MEMORY ID 'ZTMM002'.
IMPORT w_ztmm004 FROM MEMORY ID 'ZTMM004'.
IMPORT w_ztmm005 FROM MEMORY ID 'ZTMM005'.
IMPORT w_ztmm006 FROM MEMORY ID 'ZTMM006'.
IMPORT w_ztmm007 FROM MEMORY ID 'ZTMM007'.
ztmm001-zwebno = w_ztmm002-zwebno.
ztmm001-zwit = w_ztmm002-zwit.
ztmm001-zchno = w_ztmm002-zchno.
ztmm001-zstag = w_ztmm002-zstag.
ztmm001-zward = w_ztmm002-zward.
ztmm001-zwind = w_ztmm002-zwind.
ztmm001-zchsp = w_ztmm002-zchsp.
ztmm001-zcong = w_ztmm002-zcong.
ztmm001-zftyp = w_ztmm002-zftyp.
ztmm001-zedfa = w_ztmm002-zedfa.
ztmm001-zcora = w_ztmm002-zcora.
ztmm001-zband = w_ztmm002-zband.
ztmm001-zconntype = w_ztmm002-zconntype.
ztmm001-ztubetype = w_ztmm002-ztubetype.
ztmm001-zpacktype = w_ztmm002-zpacktype.
ztmm001-zod01 = w_ztmm004-zod01.
ztmm001-zid01 = w_ztmm004-zid01.
ztmm001-zod01 = w_ztmm004-zod01.
ztmm001-zlenh = w_ztmm004-zlenh.
ztmm001-zwavh = w_ztmm004-zwavh.
ztmm001-zange = w_ztmm004-zange.
ztmm001-zituc = w_ztmm004-zituc.
ztmm001-zstu1 = w_ztmm004-zstu1.
ztmm001-zsize = w_ztmm004-zsize.
* ADD BY dev14 2012-05-25---DEVK909127 -----START -----
ztmm001-ZTYPE = w_ztmm004-ZTYPE.
ztmm001-ztdjg = w_ztmm004-ztdjg.
ztmm001-zspec = w_ztmm004-zspec.
* ADD BY-------------------------------------END---------
ztmm001-zhono = w_ztmm007-zhono.
ztmm001-zrow1 = w_ztmm007-zrow1.
ztmm001-zhspa = w_ztmm007-zhspa.
ztmm001-zsmt1 = w_ztmm007-zsmt1.
ztmm001-zdip1 = w_ztmm007-zdip1.
ztmm001-zrco1 = w_ztmm007-zrco1.
ztmm001-zlath = w_ztmm007-zlath.
ztmm001-zspac = w_ztmm007-zspac.
ztmm001-zfibe = w_ztmm007-zfibe.
ztmm001-zsta1 = w_ztmm007-zsta1.
ztmm001-zglso = w_ztmm007-zglso.
ztmm002-zclor = w_ztmm005-zclor.
ztmm002-zstuf = w_ztmm005-zstuf.
ztmm002-zpaty = w_ztmm005-zpaty.
ztmm002-zpin1 = w_ztmm005-zpin1.
ztmm002-zpith = w_ztmm005-zpith.
ztmm002-zcost = w_ztmm005-zcost.
ztmm002-zplate = w_ztmm005-zplate.
ztmm002-zmaker = w_ztmm005-zmaker.
ztmm002-zmpno = w_ztmm005-zmpno.
ztmm002-zhousma = w_ztmm001-zhousma.
ztmm002-zternlma = w_ztmm001-zternlma.
ztmm002-zshelma = w_ztmm001-zshelma.
ztmm002-zmark = w_ztmm001-zmark.
ztmm002-zkey1 = w_ztmm001-zkey1.
ztmm002-zinsd = w_ztmm006-zinsd.
ztmm002-znocw = w_ztmm006-znocw.
ztmm002-zawg1 = w_ztmm006-zawg1.
ztmm002-zshst = w_ztmm006-zshst.
ztmm002-zhtpc = w_ztmm003-zhtpc.
ztmm002-zinse = w_ztmm003-zinse.
ztmm002-ztecu = w_ztmm003-ztecu.
ztmm002-zisc = w_ztmm003-zisc.
ztmm002-zprctr = w_ztmm003-zprctr.
ztmm001-matnr = cmara-matnr.
ztmm002-matnr = cmara-matnr.
*--------------------------------------------------------------------*
* CHECK
*--------------------------------------------------------------------*
IF wmara-mtart = 'Z001' OR wmara-mtart = 'Z002'.
IF wmara-matnr+1(2) NE wmara-matkl+0(2).
MESSAGE e022(zpp001).
ENDIF.
ENDIF.
IF wmara-mtart = 'Z002' OR wmara-mtart = 'Z004'.
ELSE.
* 销售视图2的 Acct assignment grp和财务视图1的valuation Class,必须match。
DATA: lw_ztmm023 TYPE ztmm023.
DATA: lw_mbew TYPE mbew.
* case1
IF wmvke-vkorg IS NOT INITIAL AND wmvke-ktgrm IS NOT INITIAL.
SELECT SINGLE * FROM ztmm023 INTO lw_ztmm023
WHERE vkorg = wmvke-vkorg
AND ktgrm = wmvke-ktgrm.
IF wmbew-matnr IS INITIAL.
SELECT SINGLE * FROM mbew INTO lw_mbew
WHERE matnr = wmvke-matnr
AND bwkey = wmvke-vkorg.
IF lw_ztmm023-bklas NE lw_mbew-bklas
AND sy-subrc = 0.
MESSAGE e021(zpp001).
ENDIF.
ELSE.
IF lw_ztmm023-bklas NE wmbew-bklas.
MESSAGE e021(zpp001).
ENDIF.
ENDIF.
ENDIF.
* case2
IF wmbew-matnr IS NOT INITIAL AND
wmvke-matnr IS INITIAL.
DATA: lw_mvke TYPE mvke.
SELECT SINGLE * FROM mvke INTO lw_mvke
WHERE matnr = wmbew-matnr
AND vkorg = wmbew-bwkey.
IF sy-subrc = 0.
SELECT SINGLE * FROM ztmm023 INTO lw_ztmm023
WHERE vkorg = lw_mvke-vkorg
AND ktgrm = lw_mvke-ktgrm.
IF lw_ztmm023-bklas NE wmbew-bklas.
MESSAGE e021(zpp001).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* SAVE
*--------------------------------------------------------------------*
IF w_ztmm001 IS INITIAL
AND w_ztmm002 IS INITIAL
AND w_ztmm003 IS INITIAL
AND w_ztmm004 IS INITIAL
AND w_ztmm005 IS INITIAL
AND w_ztmm006 IS INITIAL
AND w_ztmm007 IS INITIAL.
ELSE.
MODIFY ztmm001 FROM ztmm001.
MODIFY ztmm002 FROM ztmm002.
ENDIF.
ENDIF.
READ TABLE stext WITH KEY spras = 'Z'.
IF sy-subrc = 0.
l_maktx = stext-maktx.
ELSE.
DELETE FROM ztmm020 WHERE matnr = wmara-matnr AND spras = 'Z'.
ENDIF.
LOOP AT stext.
CLEAR lt_ztmm020.
lt_ztmm020-matnr = cmara-matnr.
lt_ztmm020-spras = stext-spras.
CONCATENATE stext-maktx ',' l_maktx INTO lt_ztmm020-maktx.
TRANSLATE lt_ztmm020-maktx TO UPPER CASE.
APPEND lt_ztmm020.
ENDLOOP.
IF lt_ztmm020[] IS NOT INITIAL.
MODIFY ztmm020 FROM TABLE lt_ztmm020.
ENDIF.
IF wmara-lvorm = 'X'.
MESSAGE '在集团级别设置删除标志!' TYPE 'E'.
ENDIF.