该操作可以参考标准示例类:CL_EXM_IM_MB_MIGO_BADI
创建一个存个性化数据的数据库表:ZMIGOT01
创建增强结构:ZMIGOS01,编辑-包括-插入,输入刚刚创建的数据库表ZMIGOT01
创建表类型ZMIGOT01_T,行类型填写刚刚创建的结构ZMIGOS01
se80创建函数组ZFGMIGO01
top中定义变量
创建模块ZMM_I_GET_DATA
创建模块ZMM_I_SET_DATA
创建更新模块ZMM_UPDATE_DATA
创建模块ZMM_SET_GOACTION
创建子屏幕 9002,绘制所需要的字段
新增pbo module,我这边设置的不允许更改
se19创建增强实施 ZIM_EN_MIGO02
创建badi实施 ZIM_EN_MIGO01,实施类 ZCL_IM_EN_MIGO01
添加属性
实现各方法内容
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 zmigos01.
CHECK i_line_id IS NOT INITIAL.
e_cprog = 'SAPLZFGMIGO01'(001). "'SAPL + 'FG Name'
e_dynnr = '9002'.
e_heading = '备注'.
g_line_id = i_line_id.
READ TABLE it_item INTO wa_item WITH KEY line_id = i_line_id.
CALL FUNCTION 'ZMM_I_SET_DATA'
EXPORTING
i_input = wa_item.
ENDIF.
ENDMETHOD.```
**IF_EX_MB_MIGO_BADI~PAI_DETAIL**
```java
METHOD if_ex_mb_migo_badi~pai_detail.
DATA: wa_item_new TYPE zmigos01,
wa_item_old TYPE zmigos01.
CHECK i_line_id <> 0.
CALL FUNCTION 'ZMM_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**
```java
METHOD if_ex_mb_migo_badi~line_modify.
DATA: wa_item_new TYPE zmigos01,
wa_item_old TYPE zmigos01,
wa_ztmm_i_migo01 TYPE zmigot01,
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 zmigot01
INTO wa_ztmm_i_migo01
WHERE mblnr = cs_goitem-mblnr
AND mjahr = cs_goitem-mjahr
AND zeile = cs_goitem-zeile.
IF wa_ztmm_i_migo01 IS NOT INITIAL.
MOVE-CORRESPONDING wa_ztmm_i_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 'ZMM_I_GET_DATA'
IMPORTING
e_output = wa_item_new.
MODIFY it_item FROM wa_item_new TRANSPORTING zztext 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: it_item,
g_no_input,
g_cancel,
g_line_id.
ENDMETHOD.
IF_EX_MB_MIGO_BADI~POST_DOCUMENT
METHOD if_ex_mb_migo_badi~post_document.
DATA: wa_ztmm_i_migo01 TYPE zmigot01,
lt_ztmm_i_migo01 TYPE TABLE OF zmigot01,
wa_item TYPE zmigos01,
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_i_migo01.
MOVE-CORRESPONDING wa_mseg TO wa_ztmm_i_migo01.
APPEND wa_ztmm_i_migo01 TO lt_ztmm_i_migo01.
ENDIF.
ENDLOOP.
CALL FUNCTION 'ZMM_UPDATE_DATA' IN UPDATE TASK
TABLES
it_item = lt_ztmm_i_migo01.
ENDIF.
ENDMETHOD.
IF_EX_MB_MIGO_BADI~MODE_SET
METHOD if_ex_mb_migo_badi~mode_set.
" i_action:
" A01 = Goods receipt
" A02 = Return delivery
" A03 = Cancellation
" A04 = Display
" A05 = Release GR bl.st.
" A06 = Subsequent deliv.
" A07 = Goods issue
"
" i_refdoc:
" R01 = Purchase order
" R02 = Material document
" R03 = Delivery note
" R04 = Inbound delivery
" R05 = Outbound delivery
" R06 = Transport
" R07 = Transport ID code
" R08 = Order
" R09 = Reservation
" R10 = Other GR
*------------------------------------------------*
IF i_action = 'A03' OR i_action = 'A04' .
g_cancel = abap_true.
ENDIF.
CALL FUNCTION 'ZMM_SET_GOACTION'
EXPORTING
i_goaction = i_action.
ENDMETHOD.
完成后激活,migo测试即可,注意如果保存不了数据,检查下函数组的get_data和set_data的类型和屏幕字段的类型是否一致