*&---------------------------------------------------------------------*
*& Report  ZFIND_EXIT_BADI
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT z_find_userexit_and_badi NO STANDARD PAGE HEADING.
*&---------------------------------------------------------------------*
*&  Enter the transaction code that you want to search through in order
*&  to find which Standard SAP User Exits and BADIs
*&
*&---------------------------------------------------------------------*
*& For field 'SUBC' of table 'TRDIR':
*&   M  Module Pool
*&   F  Function group
*&   S  Subroutine Pool
*&   J  Interface pool
*&   K  Class pool
*&   T  Type Pool
*&   X  XSLT Program
*&---------------------------------------------------------------------*
*& Tables
*&---------------------------------------------------------------------*
TABLES: tstc     , " SAP Transaction Codes
        tadir    , " Directory of Repository Objects
        modsapt  , " SAP Enhancements - Short Texts
        sxs_attrt, " SAP BADI - short text
        modact   , " Modifications
        trdir    , " System table TRDIR
        tfdir    , " Function Module
        enlfdir  , " Additional Attributes for Function Modules
        tstct    . " Transaction Code Texts

*&---------------------------------------------------------------------*
*& Variables
*&---------------------------------------------------------------------*
DATA: jtab        LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA: field1(30).
DATA: v_devclass  LIKE tadir-devclass.
DATA: object      LIKE tadir-object.
DATA: bdcdata_wa  TYPE bdcdata,
      bdcdata_tab TYPE TABLE OF bdcdata.
DATA: opt         TYPE ctu_params.

*&---------------------------------------------------------------------*
*& Selection Screen Parameters
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: exit RADIOBUTTON GROUP 1 DEFAULT 'X',
            badi RADIOBUTTON GROUP 1.
SELECTION-SCREEN END OF BLOCK a01.

DEFINE bdc_program.
  clear bdcdata_wa.
  bdcdata_wa-program  = &1.
  bdcdata_wa-dynpro   = &2.
  bdcdata_wa-dynbegin = &3.
  append bdcdata_wa to bdcdata_tab.
END-OF-DEFINITION.
DEFINE bdc_detail.
  clear bdcdata_wa.
  bdcdata_wa-fnam = &1.
  bdcdata_wa-fval = &2.
  append bdcdata_wa to bdcdata_tab.
END-OF-DEFINITION.

*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  IF exit = 'X'.
    object = 'SMOD'.  " User-exit!
  ELSE.
    object = 'SXSD'.  " BADI!
  ENDIF.

* Validate Transaction Code:
  SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
* Find Repository Objects for transaction code:
  IF sy-subrc EQ 0.                                         " IF 1
    SELECT SINGLE * FROM tadir WHERE pgmid    = 'R3TR'
                                 AND object   = 'PROG'
                                 AND obj_name = tstc-pgmna."Program name!
    MOVE: tadir-devclass TO v_devclass. " Package
    IF sy-subrc NE 0.
      SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
      IF trdir-subc EQ 'F'.  " Function Group
        SELECT SINGLE * FROM tfdir   WHERE pname    = tstc-pgmna.
        SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname.
        SELECT SINGLE * FROM tadir   WHERE pgmid    = 'R3TR'
                                       AND object   = 'FUGR'
                                       AND obj_name = enlfdir-area.
        MOVE: tadir-devclass TO v_devclass.
      ENDIF.
    ENDIF.

*   Find SAP Modifactions:
    SELECT * FROM tadir INTO TABLE jtab WHERE pgmid    = 'R3TR'
*                                          AND object   = 'SMOD'
                                          AND object   = object
                                          AND devclass = v_devclass.
    SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu
                                 AND tcode EQ p_tcode.

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
    WRITE: /(19)  'Transaction Code - ',
            20(20) p_tcode,
            45(50) tstct-ttext.
    SKIP.
    IF NOT jtab[] IS INITIAL.                               " IF 2
      WRITE: /(95) sy-uline.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
*     Exit:
      IF exit = 'X'.
        WRITE: /1  sy-vline,
                2  'Exit Name',
                22 sy-vline ,
                23 'Description',
                95 sy-vline.
*     BADI:
      ELSE.
        WRITE: /1  sy-vline,
                2  'BADI Name',
                22 sy-vline ,
                23 'Description',
                95 sy-vline.
      ENDIF.
      WRITE:/(95) sy-uline.
      LOOP AT jtab.
*       EXIT:
        IF exit = 'X'.
          SELECT SINGLE * FROM modsapt WHERE sprsl = sy-langu
                                         AND name  = jtab-obj_name.
          FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
          WRITE: /1  sy-vline,
                  2  jtab-obj_name HOTSPOT ON,
                  22 sy-vline ,
                  23 modsapt-modtext,
                  95 sy-vline.
*       BADI:
        ELSE.
          SELECT SINGLE * FROM sxs_attrt WHERE sprsl     = sy-langu
                                           AND exit_name = jtab-obj_name.
          FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
          WRITE: /1  sy-vline,
                  2  jtab-obj_name HOTSPOT ON,
                  22 sy-vline ,
                  23 sxs_attrt-text,
                  95 sy-vline.
        ENDIF.
      ENDLOOP.
      WRITE: /(95) sy-uline.
      DESCRIBE TABLE jtab.
      SKIP.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      IF exit = 'X'.
        WRITE: / 'No of Exits:', sy-tfill.
      ELSE.
        WRITE: / 'No of BADIs:', sy-tfill.
      
ENDIF.
    
ELSE.                                                   " IF 2
      
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      
WRITE: /(95) 'No User Exit exists'.
    
ENDIF.                                                  " IF 2
  
ELSE.                                                     " IF 1
    
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    
WRITE: /(95) 'Transaction Code Does Not Exist'.
  
ENDIF.                                                    " IF 1

* Take the user to SMOD for the Exit that was selected:

AT LINE-SELECTION.
  
GET CURSOR FIELD field1.
  
CHECK field1(4) EQ 'JTAB'.

* For exit:
  
IF exit = 'X'.
    
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
    
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

* For BADI:
  
ELSE.
    
CLEAR: bdcdata_wa, bdcdata_tab[].
    bdc_program 
'SAPLSEXO' '0100' 'X'.
    bdc_detail 
'BDC_CURSOR' 'G_IS_BADI'.
    bdc_detail 
'BDC_OKCODE' '=ISSPOT'.
    bdc_detail 
'G_IS_BADI' 'X'.
    bdc_program 
'SAPLSEXO' '0100' 'X'.
    bdc_detail 
'BDC_CURSOR' 'G_BADINAME'.
    bdc_detail 
'BDC_OKCODE' '=SHOW'.
    bdc_detail 
'G_BADINAME' sy-lisel+1(20).
    opt
-dismode = 'E'.
    opt
-defsize = 'X'.
    
CALL TRANSACTION 'SE18' USING bdcdata_tab OPTIONS FROM opt.
  
ENDIF.

ZFIND_EXIT_BADI的更多相关文章

随机推荐

  1. python023 Python3 标准库概览

    Python3 标准库概览 操作系统接口 os模块提供了不少与操作系统相关联的函数. >>> import os >>> os.getcwd() # 返回当前的工作 ...

  2. Linux(Centos6.5)+Nginx+PHP-fpm+Mysql配置

    第一步:准备安装包 1.从[](http://nginx.org/en/download.html).下载nginx 源码包 //NOTE! 下载稳定版本 2.从[](http://php.net/d ...

  3. 洛谷P1432 倒水问题

    题目背景 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with th ...

  4. 【转】SQL Server 创建约束图解 唯一 主键-界面操作

    SQL Server 创建约束图解 唯一 主键-界面操作 SQLServer中有五种约束,Primary Key约束.Foreign Key约束.Unique约束.Default约束和Check约束, ...

  5. hdu 4049 Tourism Planning [ 状压dp ]

    传送门 Tourism Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. hdu 4046 Panda [线段树]

    Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  7. msp430项目编程13

    msp430中项目---温湿度检测系统 1.dht11工作原理 2.电路原理说明 3.代码(显示部分) 4.代码(功能实现) 5.项目总结 msp430项目编程 msp430入门学习

  8. Pytho操作MySQL

    一.相关代码 数据库配置类 MysqlDBConn.py 01 #encoding=utf-8 02 ''' 03 Created on 2012-11-12 04    05 @author: St ...

  9. 牛客网暑期ACM多校训练营(第九场) A题 FWT

    链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...

  10. poj 3041——Asteroids

    poj       3041——Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22604   Accep ...