SAP MIGO屏幕增强的具体实施步骤介绍(SE19:MB_MIGO_BADI) <转载>

原文链接:https://mp.weixin.qq.com/s/cDoKsc3nBPMa0GRTtQawHw

在SAP/ERP项目实施中经常会遇到MIGO屏幕增强的需求,就是要在MIGO标准屏幕的抬头或行项目中添加一个客制化页签,在增强页签下增加一些字段供用户录入一些额外信息,比如如下需求:

在MIGO界面的抬头和项目都增加一个【备注信息】字段(如下图),用于做MIGO操作时候录入一些备注信息。

下面详细介绍下这个需求的具体增强实施步骤:

1.MIGO抬头屏幕增强具体增强实施步骤

1.1.创建存储抬头客制化数据的增强表

1.2.创建增强结构

1.3.创建函数组ZMM_MIGO

1.3.1.定义全局变量

1.3.2.创建数据处理函数

ZMIGO_H_GET_DATA

ZMIGO_H_SET_DATA

ZMIGO_SET_GOACTION

ZMIGO_UPDATE_DATA

1.4.创建字屏幕9001

屏幕PBO

java 复制代码
  loop at screen.

    if screen-group1 = 'G1' AND g_goaction =  'A04'.
          screen-input = 0 .
          modify screen.
    endif.
  endloop.

1.5.实施新BADI增强

SE19创建BADI实施




双击实施类ZCL_MIGO_EN_01

IF_EX_MB_MIGO_BADI~INIT

IF_EX_MB_MIGO_BADI~RESET

IF_EX_MB_MIGO_BADI~POST_DOCUMENT

java 复制代码
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

java 复制代码
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

java 复制代码
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

java 复制代码
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 = '客户数据(抬头增强屏幕)'(001).
   ENDIF.

endmethod.

IF_EX_MB_MIGO_BADI~PAI_HEADER

java 复制代码
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.增强效果确认

2.MIGO项目行屏幕增强具体增强实施步骤

2.1.创建存储行项目客制化数据的增强表

2.2.增强结构

2.3.创建增强数据表类型结构

2.4.新建Function Group

定义全局变量

ZMIGO_I_GET_DATA

ZMIGO_I_SET_DATA

创建函数ZMIGO_UPDATE_DATA(抬头/行项目:更新数据到数据库 )

java 复制代码
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.创建屏幕


java 复制代码
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.创建BADI实施(具体步骤见前文)

使用事务码SE19创建BADI实施

双击实施类ZCL_MIGO_EN_01

IF_EX_MB_MIGO_BADI~INIT

java 复制代码
method IF_EX_MB_MIGO_BADI~INIT.

APPEND gf_class_id TO ct_init.

endmethod.

IF_EX_MB_MIGO_BADI~PBO_DETAIL

java 复制代码
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 = '客户字段(项目增强屏幕)'.
    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

java 复制代码
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

java 复制代码
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

java 复制代码
method IF_EX_MB_MIGO_BADI~LINE_DELETE.
DELETE it_item WHERE line_id = i_line_id.
endmethod.

IF_EX_MB_MIGO_BADI~RESET

java 复制代码
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

java 复制代码
method if_ex_mb_migo_badi~post_document.

*MIGO屏幕抬头增强表更新
  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屏幕项目增强表更新

  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

java 复制代码
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.
相关推荐
武子康2 分钟前
Java-06 深入浅出 MyBatis - 一对一模型 SqlMapConfig 与 Mapper 详细讲解测试
java·开发语言·数据仓库·sql·mybatis·springboot·springcloud
wqq_99225027728 分钟前
springboot基于微信小程序的食堂预约点餐系统
数据库·微信小程序·小程序
爱上口袋的天空30 分钟前
09 - Clickhouse的SQL操作
数据库·sql·clickhouse
转世成为计算机大神34 分钟前
易考八股文之Java中的设计模式?
java·开发语言·设计模式
qq_327342731 小时前
Java实现离线身份证号码OCR识别
java·开发语言
Oak Zhang1 小时前
sharding-jdbc自定义分片算法,表对应关系存储在mysql中,缓存到redis或者本地
redis·mysql·缓存
聂 可 以2 小时前
Windows环境安装MongoDB
数据库·mongodb
web前端神器2 小时前
mongodb多表查询,五个表查询
数据库·mongodb
门牙咬脆骨2 小时前
【Redis】redis缓存击穿,缓存雪崩,缓存穿透
数据库·redis·缓存
门牙咬脆骨2 小时前
【Redis】GEO数据结构
数据库·redis·缓存