通过Tcode查找Badi或者客户出口

https://wiki.scn.sap.com/wiki/display/ABAP/Code+To+Find+BAdi

Created by Naresh Reddy K, last modified by Smruti Ranjan Mohanty

The following program asks for a transaction code or a program name. If a transaction code is entered, its called program is used as the program name. With the program name, its package is retrieved, and all the Enhancements (Customer Exits) and classic BAdIs of this package are displayed.

It means this program is an help to find some Enhancements (customer exits) and BAdIs in the same package, but maybe they are not related to this transaction or program, and moreover, this transaction or program may call many Enhancements (customer exits) and BAdIs which will not be listed by this program. Instead, prefer Finding a BADI using Buffer trace - Transaction ST05 (Screenshots) or Find a BADI through SPRO.

 REPORT z_find_badi NO STANDARD PAGE HEADING.

*&---------------------------------------------------------------------*
*&  Enter the transaction code or pragram name that you want to search through
*&  in order to find which Standard SAP# User Exits exists or BAdis.
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& Tables
*&---------------------------------------------------------------------*

TABLES : tstc, "SAP# Transaction Codes
         tadir,    "Directory of Repository Objects
         modsapt,  "SAP# Enhancements - Short Texts
         modact,   "Modifications
         trdir,    "System table TRDIR
         tfdir,    "Function Module
         enlfdir,  "Additional Attributes for Function Modules
         sxs_attrt,"Exit: Definition side: Attributes, Text table
         tstct.    "Transaction Code Texts

*&---------------------------------------------------------------------*
*& Variables
*&---------------------------------------------------------------------*

DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
DATA wa_tadir TYPE tadir.

*&---------------------------------------------------------------------*
*& Selection Screen Parameters
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK s01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_tcode LIKE tstc-tcode,
             p_pgmna LIKE tstc-pgmna.
SELECTION-SCREEN END OF BLOCK s01.

*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*

START-OF-SELECTION.

* Validate Transaction Code
  IF NOT p_tcode IS INITIAL.
    SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
  ELSEIF NOT p_pgmna IS INITIAL.
    tstc-pgmna = p_pgmna.
  ENDIF.

* Find Repository Objects for transaction code
  IF sy-subrc EQ 0.
    SELECT SINGLE * FROM tadir
          WHERE pgmid = ‘R3TR‘
            AND object = ‘PROG‘
            AND obj_name = tstc-pgmna.

    MOVE : tadir-devclass TO v_devclass.

    IF sy-subrc NE 0.
      SELECT SINGLE * FROM trdir
            WHERE name = tstc-pgmna.

      IF trdir-subc EQ ‘F‘.
        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 EQ enlfdir-area.

        MOVE : tadir-devclass TO v_devclass.
      ENDIF.
    ENDIF.

* Find SAP# Modifications
    SELECT * FROM tadir INTO TABLE jtab
          WHERE pgmid = ‘R3TR‘
            AND object IN (‘SMOD‘, ‘SXSD‘)
            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.
      WRITE:/(105) sy-uline.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
* Sorting the internal Table
      SORT jtab BY object.
      DATA : wf_txt(60) TYPE c,
            wf_smod TYPE i ,
            wf_badi TYPE i ,
            wf_object2(30) TYPE c.
      CLEAR : wf_smod, wf_badi , wf_object2.
* Get the total SMOD.
      LOOP AT jtab INTO wa_tadir.
        AT FIRST.
          FORMAT COLOR COL_HEADING INTENSIFIED ON.
          WRITE:/1 sy-vline,
                2 ‘Enhancement/ Business Add-in‘,
                41 sy-vline ,
                42 ‘Description‘,
                105 sy-vline.
          WRITE:/(105) sy-uline.
        ENDAT.

        CLEAR wf_txt.

        AT NEW object.
          IF wa_tadir-object = ‘SMOD‘.
            wf_object2 = ‘Enhancement‘ .
          ELSEIF wa_tadir-object = ‘SXSD‘.
            wf_object2 = ‘ Business Add-in‘.
          ENDIF.
          FORMAT COLOR COL_GROUP INTENSIFIED ON.
          WRITE:/1 sy-vline,
                2 wf_object2,
                105 sy-vline.
        ENDAT.

        CASE wa_tadir-object.
          WHEN ‘SMOD‘.
            wf_smod = wf_smod + 1.
            SELECT SINGLE modtext INTO wf_txt
                  FROM modsapt
                  WHERE sprsl = sy-langu
                    AND name = wa_tadir-obj_name.

            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
          WHEN ‘SXSD‘.
* For BADis
            wf_badi = wf_badi + 1 .
            SELECT SINGLE text INTO wf_txt
                  FROM sxs_attrt
                  WHERE sprsl = sy-langu
                    AND exit_name = wa_tadir-obj_name.

            FORMAT COLOR COL_NORMAL INTENSIFIED ON.
        ENDCASE.
        WRITE:/1 sy-vline,
              2 wa_tadir-obj_name HOTSPOT ON,
              41 sy-vline ,
              42 wf_txt,
              105 sy-vline.

        AT END OF object.
          WRITE : /(105) sy-uline.
        ENDAT.
      ENDLOOP.
      WRITE:/(105) sy-uline.
      SKIP.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      WRITE:/ ‘No.of Exits:‘ , wf_smod.
      WRITE:/ ‘No.of BADis:‘ , wf_badi.
    ELSE.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      WRITE:/(105) ‘No userexits or BADis exist‘.
    ENDIF.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE:/(105) ‘Transaction does not exist‘.
  ENDIF.

* Take the user to SMOD or SXSD for the Exit or BAdi that was selected.
AT LINE-SELECTION.
  DATA : wf_object TYPE tadir-object.
  CLEAR wf_object.
  GET CURSOR FIELD field1.
  CHECK field1(8) EQ ‘WA_TADIR‘.
  READ TABLE jtab WITH KEY obj_name = sy-lisel+1(20).
  MOVE jtab-object TO wf_object.
  CASE wf_object.
    WHEN ‘SMOD‘.
      SET PARAMETER ID ‘MON‘ FIELD sy-lisel+1(10).
      CALL TRANSACTION ‘SMOD‘ AND SKIP FIRST SCREEN.
    WHEN ‘SXSD‘.
      SET PARAMETER ID ‘EXN‘ FIELD sy-lisel+1(20).
      CALL TRANSACTION ‘SE18‘ AND SKIP FIRST SCREEN.
  ENDCASE.

*Text elements
*----------------------------------------------------------
* 001 Enter the Transaction Code or Program name that you want to search

*Selection texts
*----------------------------------------------------------
* P_PGMNA         Program name to Search
* P_TCODE         Transaction Code to Search
时间: 2024-11-05 16:08:27

通过Tcode查找Badi或者客户出口的相关文章

查找SAP标准程序用户出口及BADI的方法

查找SAP标准事务代码中使用的BADI: 在SE24中,查看类对象CL_EXITHANDLER,在其方法(Methods)GET_INSTANCE 的第14行打断点,之后运行事务代码: 当有BADI将会被执行的时候,这时候会进入类CL_EXITHANDLER的GET_INSTANCE方法,按F6执行这个方法之后,参数EXIT_NAME中的值便是BADI定义(SE18中看到的东西),参数CLASS_NAME则是类对象名称(SE24里面看到的东西),所有的方法实现都是存在于类对象中: 通过查找类方法

通过TCODE查找SPRO路径

1.SE11:CUS_ACTOBJ,根据OBJECTNAME(对象名称),即视图名称,获取Customizing activity(ACT_ID) 2.根据ACT_ID在表CUS_IMGACT获取说明文本 3.在SRPO搜索说明文本 PS:如果查找视图的SPRO路径,可以直接通过SM30初始界面点击"Customizing"按钮

SAP ABAP之第一,二,三代出口类型BADI实现 概念解释

BADI是用户的第三代出口类型,我们来看看其具体的是如何实现的. 一,用户出口的类型 1,第一代 sap提供一个空代码的子过程,在这个子过程中用户可以添加自己的代码,控制自己的需求.这类增强都需要修改sap的标准代码.示例:USEREXIT.. in SAPMV45A 2,第二代 sap提供的是CUSTOMER-FUNCTION,它是通过SMOD和CMOD完成实现. 3,第三代 sap提供的第三代的用户出口就是BADI,他的调用方式是CALL METHOD (instance),(相关的TCOD

SAP 增强篇 Method1 BADI增强的查找方法

查找BADI的方法:(1)通过SE24,输入CL_EXITHANDLER,然后在方法GET_INSTANCE中设置断点,然后运行事务代码判断 exit_name的值,操作过程如下:输入se24,然后输入cl_exithandler 找到 GET_INSTANCE 方法,双击get_instance设置断点查看exit_name的值: 示例:  我们要找PO保存的增强,可以用哪个BADI ?前台输入 ME21N,进入断点, EXIT_NAME = ME_GUI_PO_CUST F8 , EXIT_

BADI OVERVIEW

什么是BADI,如何从SAP中查找BADI? Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industri

20160410javaweb 开发小案例 --客户管理系统

客户管理系统---体验基于数据库javaweb的增删改查 添加客户 查询客户列表 修改客户信息 删除客户 条件查询客户信息 分页查询客户 javaee的经典三层架构--工厂类实现解耦 jsp+servlet+service+dao+jdbc+mysql+c3p0+dbutils com.dzq.web .service .dao .domain .util .exception .factory JSTL mysql驱动 beanutils c3p0包 dbutils包 confing.prop

ABAP Enhancement:第二部分

声明:原创作品,转载时请注明文章来自SAP师太技术博客:www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将追究法律责任!原文链接:http://www.cnblogs.com/jiangzhengjun/p/4291296.html 第三代:基于类的增强(BADI)... 25 BADI新方式实现... 42 1-构建BADI. 42 2-实现BADI. 44 3-使用BADI过滤器... 49 4-多个实现时究竟调谁... 51 查找系统中的BA

SAP中寻找增强的实现方法(转)

SAP 增强已经发展过几代了,可参考 SAP 标准教材 BC425 和 BC427.简单的说SAP的用户出口总共有四代:1.第一代  基于源代码的增强.SAP提供一个空代码的子过程,在这个子过程中用户可以添加自己的代码,控制自己的需求.这类增强都需要修改sap的标准代码.示例:USEREXIT.. in SAPMV45A 源代码增强以子程序形式发布,在 SAP 的发行版本中,使用 PERFORM 调用这些子程序,它们在发布时都是空的,集中在一些文件名倒数第二个字符为 Z 的包含程序中.用户增强时

SAP 中如何寻找增强

方法一.利用TCODE寻找增强(第二代的增强) 执行一个程序(源代码后附),在选择屏幕处输入你所需要增强的程序TCODE,执行後,就会出现一个列表,那里就有关于如何增强这个的绝大部分SMOD增强. 点击进去,自己手动寻找需要的增强. 这是第二代增强 方法二.利用系统函数寻找         MODX_FUNCTION_ACTIVE_CHECK 在这个FUNCTION的代码最后添加一个断点.执行需要增强的TCODE,如果有增强,就会自动跳入DEBUG界面.在DEBUG界面,查看f_tab字段,这里