业务场景
MIRO需要新增客制化字段展示,或者RBKP有的字段,但是INVFO没有的字段展示,或者RBKP和INVFO都存在的字段。增强点:BADI_FDCB_SUBBAS04,由于该BADI只能实例化一次,如果已经实例化过,我们新建的BADI增强就不能激活,所以我们可以先SXC_EXIT查找BADI实例化的地方,
然后SXC_ATTR查看这两个实例化激活状态,如果FPIA_APP_FU_MM这个显示是激活状态,我们就必须先给它取消激活,才可以进一步激活我们创建的BADI
效果图片
我这里是RBKP存在的字段,在INVFO里面不存在
增强结构
ACMM_VENDOR_COMPINVFO
6.建一个函数组ZFG_MIRO
LZFG_MIROTOP
FUNCTION-POOL zfg_miro. "MESSAGE-ID ..
5. INCLUDE LZFG_MIROD... " Local class definition
TABLES:invfo.
DATA: o_badi_fdcb_subbas04 TYPE REF TO if_ex_badi_fdcb_subbas04.
CONSTANTS exit_name_fdcb_subbas04 TYPE exit_def
VALUE 'BADI_FDCB_SUBBAS04'.
LZFG_MIROO01
*----------------------------------------------------------------------*
***INCLUDE LZFG_MIROO01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module GET_INSTANCE OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE get_instance OUTPUT.
IF o_badi_fdcb_subbas04 IS INITIAL.
CALL METHOD cl_exithandler=>get_instance_for_subscreens
CHANGING
instance = o_badi_fdcb_subbas04
EXCEPTIONS
no_reference = 1
no_interface_reference = 2
no_exit_interface = 3
data_incons_in_exit_managem = 4
class_not_implement_interface = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
* object created
CHECK NOT o_badi_fdcb_subbas04 IS INITIAL.
* get data from main screen
CALL METHOD o_badi_fdcb_subbas04->get_data_from_screen_object
IMPORTING
ex_invfo = invfo.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module SCREEN_MODIFY OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE screen_modify OUTPUT.
LOOP AT SCREEN.
CASE sy-tcode.
WHEN 'FB60' OR 'FB65' OR 'FB70' OR 'FB75'
OR 'MIRO' OR 'MIRA' OR 'MIR7'.
screen-input = 1.
WHEN OTHERS.
screen-input = 0.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE.
LZFG_MIROI01
*----------------------------------------------------------------------*
***INCLUDE LZFG_MIROI01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module RECEIVE_ACTUAL_DATA INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE receive_actual_data INPUT.
* object created
CHECK NOT o_badi_fdcb_subbas04 IS INITIAL.
* get data from main screen
CALL METHOD o_badi_fdcb_subbas04->get_data_from_screen_object
IMPORTING
ex_invfo = invfo.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
* object created
CHECK NOT o_badi_fdcb_subbas04 IS INITIAL.
* put data to main screen
CALL METHOD o_badi_fdcb_subbas04->put_data_to_screen_object
EXPORTING
im_invfo = invfo.
ENDMODULE.
屏幕:9001
PROCESS BEFORE OUTPUT.
* MODULE STATUS_9001.
MODULE get_instance.
MODULE screen_modify.
PROCESS AFTER INPUT.
MODULE receive_actual_data.
FIELD:invfo-ername.
MODULE user_command_9001.
METHOD if_ex_badi_fdcb_subbas04~put_data_to_screen_object.
me->if_ex_badi_fdcb_subbas04~invfo = im_invfo.
ENDMETHOD.
GET_DATA_FROM_SCREEN_OBJECT
METHOD if_ex_badi_fdcb_subbas04~get_data_from_screen_object.
ex_invfo = me->if_ex_badi_fdcb_subbas04~invfo.
ENDMETHOD.