MIGO新增页签增强
1、文档说明
本方法是将新增字段,展示在MIGO的新增页签中,并保存到自建表。
新增页签的方法,和采购订单新增页签的方法原理基本一致,都是需要创建函数组,并实现相应方法和屏幕,并在增强中调用该函数组,展示出屏幕,实现对应操作。
2、实现过程
2.1、创建自建表和结构
自建表中存储物料凭证主键和增强的字段ZNUM单据号
参考自建表,创建对应的结构,用于函数组数据传递
创建表类型,用于增强实施类
2.2、增强和函数组
为了清楚的展示增强和调用的函数之间的关系,此处将增强和函数实现放在一起讲解
2.2.1、创建增强实施和函数组
根据增强点MB_MIGO_BADI创建实施
点击实施类,添加表类型到实施类属性
创建函数组ZEMIGO,并声明全局变量
2.2.2、初始化
实现增强方法IF_EX_MB_MIGO_BADI~INIT
"--------------------@斌将军-------------------- method IF_EX_MB_MIGO_BADI~INIT. APPEND gf_class_id TO ct_init. endmethod. "--------------------@斌将军--------------------
2.2.3、实现PBO
创建SET函数ZEMIGO_SET_DATA
创建子屏幕9001,类型选择子屏幕
实现增强方法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 zspp001. CHECK i_line_id IS NOT INITIAL. e_cprog = 'SAPLZEMIGO'."函数组 e_dynnr = '9001'."展示的页签屏幕 e_heading = '客户数据'."页签标题 g_line_id = i_line_id. READ TABLE it_item INTO wa_item WITH KEY line_id = i_line_id. CALL FUNCTION 'ZEMIGO_SET_DATA' EXPORTING i_input = wa_item. ENDIF. ENDMETHOD. "--------------------@斌将军--------------------
2.2.4、实现PAI
创建GET函数ZEMIGO_GET_DATA
实现增强方法IF_EX_MB_MIGO_BADI~PAI_DETAIL
"--------------------@斌将军-------------------- METHOD if_ex_mb_migo_badi~pai_detail. DATA: wa_item_new TYPE zspp001, wa_item_old TYPE zspp001. CHECK i_line_id <> 0. CALL FUNCTION 'ZEMIGO_GET_DATA' IMPORTING e_out = wa_item_new. MODIFY it_item FROM wa_item_new TRANSPORTING znum WHERE line_id = i_line_id. READ TABLE it_item INTO wa_item_old WITH KEY line_id = i_line_id. IF wa_item_new-line_id <> i_line_id. e_force_change = 'X'. ENDIF. ENDMETHOD. "--------------------@斌将军--------------------
2.2.5、实现MODIFY
实现增强方法IF_EX_MB_MIGO_BADI~LINE_MODIFY
"--------------------@斌将军-------------------- METHOD if_ex_mb_migo_badi~line_modify. DATA: wa_item_new TYPE zspp001, wa_item_old TYPE zspp001, wa_ztmm_i_migo01 TYPE ztpp001, 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 ztpp001 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 'ZEMIGO_GET_DATA' IMPORTING e_out = wa_item_new. * wa_item_new-line_id = i_line_id. MODIFY it_item FROM wa_item_new TRANSPORTING znum WHERE line_id = i_line_id. ENDIF. ENDMETHOD. "--------------------@斌将军--------------------
2.2.6、实现DELETE
实现增强方法IF_EX_MB_MIGO_BADI~LINE_DELETE
"--------------------@斌将军-------------------- METHOD IF_EX_MB_MIGO_BADI~LINE_DELETE. DELETE TABLE it_item WITH TABLE KEY line_id = i_line_id. ENDMETHOD. "--------------------@斌将军--------------------
2.2.7、实现RESET
实现增强方法IF_EX_MB_MIGO_BADI~RESET
"--------------------@斌将军-------------------- METHOD IF_EX_MB_MIGO_BADI~RESET. * Clear all internal data: CLEAR: gt_extdata, g_no_input, gs_exdata_header, g_cancel, it_item, g_line_id. ENDMETHOD. "--------------------@斌将军--------------------
2.2.8、实现存表
创建UPDATE函数ZEMIGO_UPDATE_DATA
选择处理类型
实现增强方法IF_EX_MB_MIGO_BADI~POST_DOCUMENT
"--------------------@斌将军-------------------- METHOD if_ex_mb_migo_badi~post_document. DATA: wa_ztmm_i_migo01 TYPE ztpp001, lt_ztmm_i_migo01 TYPE TABLE OF ztpp001, wa_item TYPE zspp001, 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 'ZEMIGO_UPDATE_DATA' IN UPDATE TASK TABLES t_item = lt_ztmm_i_migo01. ENDIF. ENDMETHOD. "--------------------@斌将军--------------------
2.2.9、控制编辑状态
可以通过里面对应的ACTION,来控制增强字段的显示效果,比如在A04显示物料凭证时,设置增强字段为不可更改
创建函数ZEMIGO_SET_GOACTION接收ACTION
实现屏幕流
实现增强方法IF_EX_MB_MIGO_BADI~MODE_SET
"--------------------@斌将军-------------------- METHOD if_ex_mb_migo_badi~mode_set. * ACTION and REFDOC will discribe the mode of transaction MIGO. * ---------------------------------------------------------------------- * 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 *----------------------------------------------------------------------- * In case of 'DISPLAY' the global field G_NO_INPUT will be set to 'X'. * The result is that a different external subscreen will be choosen in * method PBO_DETAIL. IF i_action = 'A04' OR i_action = 'A03'. g_no_input = 'X'. ENDIF. * In case of 'CANCEL' the global field G_CANCEL will be set to 'X'. * The result is that in method POST_DOCUMENT a different handling is * used IF i_action = 'A03'. g_cancel = 'X'. ENDIF. CALL FUNCTION 'ZEMIGO_SET_GOACTION' EXPORTING i_goaction = i_action. ENDMETHOD. "--------------------@斌将军--------------------
2.3、测试效果
存表成功
到此,MIGO新增页签就实现了
定期更文,欢迎关注