SMOD增强的批量查看/搜索工具

67e49ef43d6bfeccfc080d9aa2369028.png

作为第二代增强,SMOD的使用还是挺多的,但是SAP一直没有SMOD增强清单的批量查看工具,如果想在SMOD增强中查看已经实施的或者激活的增强,或者想判断指定字符串是否在此种增强中出现,都比较困难,今天这个工具就是解决这个问题的。

此程序大概是我2007年前后写的,后面略做了少许修改,代码还比较幼稚,各位看官见谅。

*&---------------------------------------------------------------------*
*& Report  ZSMOD_DISPLAY
*&
*&---------------------------------------------------------------------*
*& SMOD批量查看
*& BAITIANZHEN
*&---------------------------------------------------------------------*
REPORT zsmod_display NO STANDARD PAGE HEADING LINE-COUNT 99999.


TYPE-POOLS: slis,icon.
TABLES: mod0.
DATA: fldct TYPE slis_t_fieldcat_alv,
      slayt TYPE slis_layout_alv,
      varnt LIKE disvariant,
      repid LIKE sy-repid,
      subrc LIKE sy-subrc.
TYPES: BEGIN OF s_function,
         fname   LIKE mod0-funcname,
         ftext   LIKE tftit-stext,
         impl,
         active,
         example,
       END OF s_function.
TYPES: BEGIN OF s_cua,
         p_name LIKE mod0-cuaprog,
         fcode  TYPE gui_code,
         impl,
         active,
       END OF s_cua.
TYPES: BEGIN OF s_screen,
         g_name  LIKE mod0-gdynprog,
         g_dynnr LIKE mod0-gdynnr,
         bername LIKE mod0-bername,
         c_name  LIKE mod0-cdynprog,
         c_dynnr LIKE mod0-cdynnr,
         text    LIKE mod0-stext,
         impl,
         active,
       END OF s_screen.
TYPES: BEGIN OF s_table,
         tname  TYPE itabname,
         impl,
         active,
       END OF s_table.
TYPES: BEGIN OF exit_members,
         name      TYPE modname,
         text      LIKE mod0-memtext,
         functions TYPE s_function OCCURS 0,
         fcodes    TYPE s_cua      OCCURS 0,
         screens   TYPE s_screen   OCCURS 0,
         tables    TYPE s_table    OCCURS 0,
         status    LIKE modattr-status,
       END OF exit_members.
DATA: exitdata     TYPE exit_members,
      wa_functions TYPE s_function,
      wa_fcodes    TYPE s_cua,
      wa_screens   TYPE s_screen,
      wa_tables    TYPE s_table,
      rcode(5).
DATA: BEGIN OF it_name OCCURS 0,
        name   LIKE modsap-name,
        status LIKE modattr-status,
      END OF it_name.
DATA: BEGIN OF it_out OCCURS 0,
        name       LIKE mod0-name,
        text       LIKE mod0-memtext,
        status     LIKE modattr-status,
        typt       LIKE mod0-typt,
        member     LIKE mod0-member,
        zprog(30),
        cmod(8),
        dynp(4),
        impl(4)    ,
        findstr(4),
        active(4)  ,
      END OF it_out.


SELECT-OPTIONS: s_name FOR mod0-name DEFAULT 'MM06E005' .
PARAMETERS: p_str TYPE string.
PARAMETERS: p_actv AS CHECKBOX,
            p_avai AS CHECKBOX.


AT SELECTION-SCREEN OUTPUT.
  %_s_name_%_app_%-text = '增强'.
  %_p_actv_%_app_%-text = '只显示已激活的增强'.
  %_p_avai_%_app_%-text = '判断函数代码是否有效'.
  %_p_str_%_app_%-text  = '在实施代码中搜索字符串(含INCLUDE)'.


START-OF-SELECTION.
  PERFORM getdata.
  PERFORM outdata.


*&---------------------------------------------------------------------*
*&      Form  getdata
*&---------------------------------------------------------------------*
FORM getdata.
  DATA: lt_incl TYPE TABLE OF smod_names WITH HEADER LINE .
  DATA: lt_code TYPE STANDARD TABLE OF char256 WITH HEADER LINE.


  CLEAR lt_incl[].
  lt_incl-itype = 'C'.
  APPEND lt_incl.


  SELECT name INTO CORRESPONDING FIELDS OF TABLE it_name
    FROM modsap
    WHERE name IN s_name AND
          typ = ''.
  LOOP AT it_name.
    CLEAR exitdata.


    PERFORM get_exit_members(saplsmod) USING it_name-name
                                       CHANGING exitdata rcode.
    IF p_actv = 'X'.
      CHECK exitdata-status <> ''.
    ENDIF.


    it_name-status = exitdata-status.
    MODIFY it_name.


    CLEAR it_out-cmod.
    SELECT SINGLE name INTO it_out-cmod
      FROM modact
      WHERE member = it_name-name AND
            typ = ''.


    it_out-name = it_name-name.
    it_out-text = exitdata-text.
    it_out-status = exitdata-status.


    LOOP AT exitdata-functions INTO wa_functions.
      it_out-typt = '函数'.
      it_out-member = wa_functions-fname.


      CALL FUNCTION 'MOD_FUNCTION_INCLUDE'
        EXPORTING
          funcname   = wa_functions-fname
        TABLES
          incl_names = lt_incl
        EXCEPTIONS
          OTHERS     = 4.
      READ TABLE lt_incl INDEX 1.
      IF sy-subrc = 0.
        it_out-zprog = lt_incl-iname.
      ENDIF.


      CLEAR: it_out-findstr,it_out-impl.
      PERFORM fillicon USING wa_functions-impl wa_functions-active
                       CHANGING it_out-impl it_out-active.
      IF wa_functions-impl = 'X' .
        IF p_avai = 'X' .
          READ REPORT it_out-zprog INTO lt_code.
          IF sy-subrc = 0.
            LOOP AT lt_code.
              CONDENSE lt_code.
              IF lt_code+0(1) <> '*' AND lt_code+0(1) <> '"' AND lt_code+0(1) <> ' '.
                it_out-impl = icon_checked ."'@01@'.
                EXIT .
              ENDIF.
              it_out-impl = icon_led_inactive ."'@BZ@'.
            ENDLOOP.
          ELSE.
            it_out-impl = icon_led_inactive. "'@BZ@'.
          ENDIF.
        ENDIF.


        CONDENSE p_str.
        IF p_str <> ''.
          PERFORM find_porg USING it_out-zprog p_str CHANGING subrc.
          IF subrc = 0.
            it_out-findstr = icon_search .
          ELSE.
            it_out-findstr = '' .
          ENDIF.
        ENDIF.
      ENDIF.
      APPEND it_out.
    ENDLOOP.


    CLEAR: it_out-zprog,it_out-findstr.
    LOOP AT exitdata-fcodes INTO wa_fcodes.
      it_out-typt = '菜单'.
      it_out-member = wa_fcodes-p_name.
      PERFORM fillicon USING wa_fcodes-impl wa_fcodes-active
                       CHANGING it_out-impl it_out-active.
      APPEND it_out.
    ENDLOOP.


    LOOP AT exitdata-screens INTO wa_screens.
      it_out-typt = '屏幕'.
      it_out-member = wa_screens-g_name.
      it_out-dynp   = wa_screens-g_dynnr.
      PERFORM fillicon USING wa_screens-impl wa_screens-active
                       CHANGING it_out-impl it_out-active.
      APPEND it_out.
    ENDLOOP.


    LOOP AT exitdata-tables INTO wa_tables.
      it_out-typt = '表'.
      it_out-member = wa_tables-tname.
      PERFORM fillicon USING wa_tables-impl wa_tables-active
                       CHANGING it_out-impl it_out-active.
      APPEND it_out.
    ENDLOOP.
    CLEAR it_out.
  ENDLOOP.
ENDFORM.                    "getdata


*&---------------------------------------------------------------------*
*&      Form  fillicon
*&---------------------------------------------------------------------*
FORM fillicon USING impl active
              CHANGING oimcl oactive.
  IF impl = 'X'.
    oimcl = icon_checked . "'@01@'.
  ELSE.
    oimcl = ''.
  ENDIF.


  IF active = 'X'..
    oactive = icon_led_green . "'@5B@'.
  ELSE.
    oactive = ''.
  ENDIF.
ENDFORM.                    "fillicon
*&---------------------------------------------------------------------*
*&      Form  outdata
*&---------------------------------------------------------------------*
FORM outdata.
  slayt-colwidth_optimize = 'X'.
  slayt-zebra             = 'X'.
  slayt-detail_initial_lines = 'X'.   "&ETA 空单元格也显示
  repid = sy-repid.


  PERFORM catlg_set USING: 'NAME   ' '' '' '增强',
                           'TEXT   ' '' '' '增强描述',
                           'STATUS ' '' '' '激活状态',
                           'CMOD   ' '' '' 'CMOD',
                           'TYPT   ' '' '' '类型',
                           'MEMBER ' '' '' '对象名',
                           'ZPROG  ' '' '' 'ZPROG',
                           'IMPL   ' '' '' '已实施',
                           'FINDSTR' '' '' '搜索结果',
                           'ACTIVE ' '' '' '激活状态' .


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = repid
      it_fieldcat             = fldct[]
      i_save                  = 'A'
      is_layout               = slayt
      i_callback_user_command = 'USER_COMMAND'
    TABLES
      t_outtab                = it_out
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.


ENDFORM.                    " outdata


*---------------------------------------------------------------------*
*       FORM frm_catlg_set                                            *
*---------------------------------------------------------------------*
FORM catlg_set USING p_field p_reftab p_reffld p_text.
  DATA: ls_fldct TYPE slis_fieldcat_alv.


  ls_fldct-fieldname     =  p_field.
  ls_fldct-seltext_l     =  p_text.
  ls_fldct-ddictxt       =  'L'.
  ls_fldct-ref_fieldname =  p_reffld.
  ls_fldct-ref_tabname   =  p_reftab.


  CASE ls_fldct-fieldname .
    WHEN 'IMPL' OR 'FINDSTR' .
      ls_fldct-icon    = 'X'.
      ls_fldct-hotspot = 'X'.
    WHEN 'ACTIVE' .
      ls_fldct-icon = 'X'.
  ENDCASE.


  APPEND ls_fldct TO fldct .
  CLEAR ls_fldct .
ENDFORM.                    "catlg_set


*&--------------------------------------------------------------------*
*&      Form  user_command
*&--------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                    rs_selfield TYPE slis_selfield.


  CASE r_ucomm.
    WHEN '&IC1'. "双击
      CHECK rs_selfield-tabindex <> 0 . "小计行总计行什么的忽略
      READ TABLE it_out INDEX rs_selfield-tabindex.
      CASE rs_selfield-fieldname.
        WHEN 'IMPL' OR 'ZPROG' OR 'FINDSTR' .
          CHECK rs_selfield-value <> ''.
          CASE it_out-typt.
            WHEN '函数'.
              PERFORM jump USING 'REPS' it_out-zprog ''.
            WHEN '屏幕'.
              PERFORM jump USING 'DYNP' it_out-dynp it_out-member.
            WHEN '表'.
              PERFORM jump USING 'STRU' it_out-member ''.
            WHEN '菜单'.
          ENDCASE.
        WHEN 'MEMBER'.
          IF it_out-typt = '函数'.
            PERFORM jump USING 'FUNC' it_out-member ''.
          ENDIF.
        WHEN 'NAME'.
          CALL FUNCTION 'MOD_COMPONENTS'
            EXPORTING
              mode               = 'CHAM'
              modname            = it_out-name
              p_standard         = 'SAP'
            EXCEPTIONS
              permission_failure = 1
              not_found          = 2
              OTHERS             = 3.
        WHEN OTHERS.
      ENDCASE.
  ENDCASE.
ENDFORM. "user_com


*&---------------------------------------------------------------------*
*&      Form  jump
*&---------------------------------------------------------------------*
FORM jump USING objtype objname object.


  CALL FUNCTION 'RS_TOOL_ACCESS'
    EXPORTING
      operation        = 'SHOW'
      object_name      = objname
      object_type      = objtype
      enclosing_object = object
    EXCEPTIONS
      OTHERS           = 4.
ENDFORM.                    "jump


*&---------------------------------------------------------------------*
*&      Form  find_porg
*&---------------------------------------------------------------------*
FORM find_porg USING progname sstr
               CHANGING subrc.
  DATA: lt_incl TYPE TABLE OF char100 WITH HEADER LINE.
  DATA: lt_code TYPE STANDARD TABLE OF char256 WITH HEADER LINE.


  CALL FUNCTION 'GET_INCLUDETAB'
    EXPORTING
      progname = progname
    TABLES
      incltab  = lt_incl.
  APPEND progname TO lt_incl.


  subrc = 4.
  LOOP AT lt_incl.
    CLEAR lt_code[].
    READ REPORT lt_incl INTO lt_code.
    FIND FIRST OCCURRENCE OF sstr IN TABLE lt_code IGNORING CASE.
    IF sy-subrc = 0.
      subrc = 0.
      RETURN.
    ENDIF.
  ENDLOOP.
ENDFORM.                    "find_porg

c733229102c2548df6c91c5dd971b25a.jpeg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值