咨詢或探討sap相關(guān)的學(xué)習(xí)、就業(yè)、技術(shù)問題! 聲明:本文僅代表作者觀點(diǎn)和立場(chǎng),不代表任何公司!僅用于SAP軟件應(yīng)用學(xué)習(xí)參考。在SAP/ERP項(xiàng)目實(shí)施中經(jīng)常會(huì)遇到MIGO屏幕增強(qiáng)的需求,就是要在MIGO標(biāo)準(zhǔn)屏幕的抬頭或行項(xiàng)目中添加一個(gè)客制化頁(yè)簽,在增強(qiáng)頁(yè)簽下增加一些字段供用戶錄入一些額外信息,比如如下需求:
在MIGO界面的抬頭和項(xiàng)目都增加一個(gè)【備注信息】字段(如下圖),用于做MIGO操作時(shí)候錄入一些備注信息。
下面詳細(xì)介紹下這個(gè)需求的具體增強(qiáng)實(shí)施步驟:
1.MIGO抬頭屏幕增強(qiáng)具體增強(qiáng)實(shí)施步驟
1.1.創(chuàng)建存儲(chǔ)抬頭客制化數(shù)據(jù)的增強(qiáng)表
1.2.創(chuàng)建增強(qiáng)結(jié)構(gòu)
1.3.創(chuàng)建函數(shù)組ZMM_MIGO
1.3.1.定義全局變量
1.3.2.創(chuàng)建數(shù)據(jù)處理函數(shù)
ZMIGO_H_GET_DATA
ZMIGO_H_SET_DATA
ZMIGO_SET_GOACTION
ZMIGO_UPDATE_DATA
1.4.創(chuàng)建字屏幕9001 屏幕PBO
loop at screen.
if screen-group1 = 'G1' AND g_goaction = 'A04'. screen-input = 0 . modify screen. endif. endloop.
1.5.實(shí)施新BADI增強(qiáng) SE19創(chuàng)建BADI實(shí)施 雙擊實(shí)施類ZCL_MIGO_EN_01
IF_EX_MB_MIGO_BADI~INIT
IF_EX_MB_MIGO_BADI~RESET IF_EX_MB_MIGO_BADI~POST_DOCUMENT method if_ex_mb_migo_badi~post_document.
if is_head is not initial.
data: wa_head type zstr_mkpf. wa_head-mandt = sy-mandt. wa_head-mblnr = is_mkpf-mblnr. wa_head-mjahr = is_mkpf-mjahr. wa_head-zmark = is_head-zmark.
call function 'ZMIGO_UPDATE_DATA' in update task exporting i_head = wa_head. endif.
endmethod.
IF_EX_MB_MIGO_BADI~MODE_SET method IF_EX_MB_MIGO_BADI~MODE_SET.
if i_action = 'A03' or i_action = 'A04' . g_no_input = abap_true. endif. if i_action = 'A03'. g_cancel = abap_true. endif.
call function 'ZMIGO_SET_GOACTION' exporting i_goaction = i_action.
endmethod.
IF_EX_MB_MIGO_BADI~STATUS_AND_HEADER method if_ex_mb_migo_badi~status_and_header.
if is_gohead-mblnr is not initial and is_gohead-mjahr is not initial and is_head is initial.
select single * from ztab_mkpf into is_head where mblnr = is_gohead-mblnr and mjahr = is_gohead-mjahr.
endif.
endmethod.
IF_EX_MB_MIGO_BADI~PBO_HEADER
method IF_EX_MB_MIGO_BADI~PBO_HEADER.
IF gf_class_id = i_class_id. CALL FUNCTION 'ZMIGO_H_SET_DATA' EXPORTING i_input = is_head. e_cprog = 'SAPLZMM_MIGO'. "'SAPL' + 'FG Name' e_dynnr = '9001'. e_heading = '客戶數(shù)據(jù)(抬頭增強(qiáng)屏幕)'(001). ENDIF.
endmethod.
IF_EX_MB_MIGO_BADI~PAI_HEADER method if_ex_mb_migo_badi~pai_header. data: wa_head type zstr_mkpf. call function 'ZMIGO_H_GET_DATA' importing e_output = wa_head. is_head = wa_head. endmethod.
1.6.增強(qiáng)效果確認(rèn) 2.MIGO項(xiàng)目行屏幕增強(qiáng)具體增強(qiáng)實(shí)施步驟
2.1.創(chuàng)建存儲(chǔ)行項(xiàng)目客制化數(shù)據(jù)的增強(qiáng)表 2.2.增強(qiáng)結(jié)構(gòu)
2.3.創(chuàng)建增強(qiáng)數(shù)據(jù)表類型結(jié)構(gòu) 2.4.新建Function Group
定義全局變量 ZMIGO_I_GET_DATA ZMIGO_I_SET_DATA 創(chuàng)建函數(shù)ZMIGO_UPDATE_DATA(抬頭/行項(xiàng)目:更新數(shù)據(jù)到數(shù)據(jù)庫(kù) )
function zmigo_update_data. *"---------------------------------------------------------------------- *"*"本地接口: *" IMPORTING *" VALUE(I_HEAD) TYPE ZSTR_MKPF OPTIONAL *" TABLES *" IT_ITEM STRUCTURE ZTAB_MESG *"---------------------------------------------------------------------- data : wa_head type zstr_mkpf. if i_head is not initial . wa_head = i_head . modify ztab_mkpf from wa_head. endif. if it_item[] is not initial . modify ztab_mesg from table it_item[] . endif.
endfunction.
ZMIGO_SET_GOACTION 2.6.創(chuàng)建屏幕 module STATUS_9002 output. * SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'.
loop at screen.
if screen-group1 = 'G1' and g_goaction = 'A04'. screen-input = 0 . modify screen. endif. endloop.
endmodule.
2.7.創(chuàng)建BADI實(shí)施(具體步驟見前文) 使用事務(wù)碼SE19創(chuàng)建BADI實(shí)施 雙擊實(shí)施類ZCL_MIGO_EN_01
IF_EX_MB_MIGO_BADI~INIT method IF_EX_MB_MIGO_BADI~INIT.
APPEND gf_class_id TO ct_init.
endmethod.
IF_EX_MB_MIGO_BADI~PBO_DETAIL method if_ex_mb_migo_badi~pbo_detail.
if gf_class_id = i_class_id. data: wa_item type zstr_mesg.
check i_line_id is not initial. e_cprog = 'SAPLZMM_MIGO'(001). "'SAPL + 'FG Name' e_dynnr = '9002'. e_heading = '客戶字段(項(xiàng)目增強(qiáng)屏幕)'. g_line_id = i_line_id. read table it_item into wa_item with key line_id = i_line_id.
call function 'ZMIGO_I_SET_DATA' exporting i_input = wa_item. endif.
endmethod.
IF_EX_MB_MIGO_BADI~PAI_DETAIL method if_ex_mb_migo_badi~pai_detail.
data: wa_item_new type zstr_mesg, wa_item_old type zstr_mesg.
check i_line_id <> 0.
call function 'ZMIGO_I_GET_DATA' importing e_output = wa_item_new.
read table it_item into wa_item_old with key line_id = i_line_id. if wa_item_new <> wa_item_old. e_force_change = 'X'. endif.
endmethod.
IF_EX_MB_MIGO_BADI~LINE_MODIFY method if_ex_mb_migo_badi~line_modify.
data: wa_item_new type zstr_mesg, wa_item_old type zstr_mesg, wa_ztmm_migo01 type ztab_mesg, l_subrc type sy-subrc.
read table it_item into wa_item_old with key line_id = i_line_id. l_subrc = sy-subrc. if sy-subrc <> 0. if cs_goitem-mblnr is not initial and cs_goitem-mjahr is not initial and cs_goitem-zeile is not initial.
select single * from ztab_mesg into wa_ztmm_migo01 where mblnr = cs_goitem-mblnr and mjahr = cs_goitem-mjahr and zeile = cs_goitem-zeile.
if wa_ztmm_migo01 is not initial. move-corresponding wa_ztmm_migo01 to wa_item_new. endif. endif.
wa_item_new-line_id = i_line_id. insert wa_item_new into table it_item. else. check g_line_id = i_line_id. call function 'ZMIGO_I_GET_DATA' importing e_output = wa_item_new.
modify it_item from wa_item_new transporting zmark where line_id = i_line_id. endif.
endmethod.
IF_EX_MB_MIGO_BADI~LINE_DELETE method IF_EX_MB_MIGO_BADI~LINE_DELETE. DELETE it_item WHERE line_id = i_line_id. endmethod.
IF_EX_MB_MIGO_BADI~RESET method IF_EX_MB_MIGO_BADI~RESET. clear : is_head, g_no_input, g_cancel, g_line_id. endmethod.
IF_EX_MB_MIGO_BADI~POST_DOCUMENT method if_ex_mb_migo_badi~post_document.
*MIGO屏幕抬頭增強(qiáng)表更新 if is_head is not initial. data: wa_head type zstr_mkpf. wa_head-mandt = sy-mandt. wa_head-mblnr = is_mkpf-mblnr. wa_head-mjahr = is_mkpf-mjahr. wa_head-zmark = is_head-zmark.
call function 'ZMIGO_UPDATE_DATA' in update task exporting i_head = wa_head. endif.
*MIGO屏幕項(xiàng)目增強(qiáng)表更新
data: wa_ztmm_migo01 type ztab_mesg, lt_ztmm_migo01 type table of ztab_mesg, wa_item type zstr_mesg, wa_mseg type mseg.
if it_item is not initial. loop at it_item into wa_item. if g_cancel is initial. read table it_mseg into wa_mseg with key line_id = wa_item-line_id. else. read table it_mseg into wa_mseg with key smbln = wa_item-mblnr smblp = wa_item-zeile sjahr = wa_item-mjahr. endif. if sy-subrc is initial. move-corresponding wa_item to wa_ztmm_migo01. move-corresponding wa_mseg to wa_ztmm_migo01. append wa_ztmm_migo01 to lt_ztmm_migo01. endif. endloop. call function 'ZMIGO_UPDATE_DATA' in update task tables it_item = lt_ztmm_migo01. endif.
endmethod.
IF_EX_MB_MIGO_BADI~MODE_SET method IF_EX_MB_MIGO_BADI~MODE_SET.
if i_action = 'A03' or i_action = 'A04' . g_no_input = abap_true. endif. if i_action = 'A03'. g_cancel = abap_true. endif.
call function 'ZMIGO_SET_GOACTION' exporting i_goaction = i_action.
endmethod.
|