`
evangxli
  • 浏览: 230691 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

SAP Code 增强

阅读更多
REPORT  Z_FIND_BADI.
*&---------------------------------------------------------------------*
*& Enter the transaction code that you want to search through in order *
*& to find which Standard SAP User Exits and BADI exists.              *
*&                                                                     *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& 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
         TSTCT,   " Transaction Code Texts
         RSSTCD,  " Screen fields for transaction code maintenance
         TRKEY.   " Complete Key of a Transport Object
*&---------------------------------------------------------------------*
*& Definition of Types                                                 *
*&---------------------------------------------------------------------*
TYPES: BEGIN OF T_BADI_LIST,
  OBJ_NAME TYPE SOBJ_NAME ,   " Object Name in Object Directory
  DEVCLASS TYPE DEVI_CLASS ,  " Function Group Package
  DLVUNIT  TYPE DLVUNIT,      " Software Component
  IMP_NAME TYPE EXIT_IMP ,    " Business Add-In Implementation
  PACKNAME TYPE DEVCLASS ,    " Package
  DLVUNIT2 TYPE DLVUNIT,      " Software Component
  TEXT     TYPE SXC_ATTRT-TEXT," Exit: Text table
END OF T_BADI_LIST.

TYPES: BEGIN OF T_BADI_LIST2,
  OBJ_NAME TYPE SOBJ_NAME ,
  DEVCLASS TYPE DEVI_CLASS ,
  DLVUNIT  TYPE DLVUNIT,
END OF T_BADI_LIST2.
*&---------------------------------------------------------------------*
*& Data Declaration                                                    *
*&---------------------------------------------------------------------*
DATA: LT_BADI_LIST  TYPE TABLE OF T_BADI_LIST,
      LT_BADI_LIST2 TYPE TABLE OF T_BADI_LIST2,
      LS_BADI_LIST  TYPE T_BADI_LIST OCCURS 0 WITH HEADER LINE,
      LS_BADI_LIST2 TYPE T_BADI_LIST2.

RANGES: R_BADI  FOR TADIR-OBJ_NAME , " Directory of Repository Objects
        RT_BADI FOR TADIR-OBJ_NAME .

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

DATA : JTAB    LIKE TADIR OCCURS 0 WITH HEADER LINE,
       P_TRKEY LIKE TRKEY. " Complete Key of a Transport Object
DATA : FIELD1(30),
       BADINAME(20),
       COUNT TYPE P.

DATA : V_DEVCLASS  LIKE TADIR-DEVCLASS,
      P_DEVCLASS  LIKE TADIR-DEVCLASS,
      P_OLD_LANGU LIKE SY-LANGU,
      P_MOD_LANGU LIKE SY-LANGU.

*&---------------------------------------------------------------------*
*& Selection Screen Parameters                                         *
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A01 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
PARAMETERS:
P_TCODE LIKE TSTC-TCODE OBLIGATORY. " SAP Transaction Codes
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK A01.

*&---------------------------------------------------------------------*
*& Start of report                                                     *
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Validate Transaction Code
  SELECT SINGLE *
    FROM TSTC
   WHERE TCODE EQ P_TCODE.
*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.
* This section is used if a FGR is involved!
      CALL FUNCTION 'RS_ACCESS_PERMISSION'
        EXPORTING
          GLOBAL_LOCK             = 'X'
          OBJECT                  = P_TCODE
          OBJECT_CLASS            = 'TRAN'
          MODE                    = 'SHOW'
          LANGUAGE_UPD_EXIT       = 'RS_TRANSACTION_LANGUAGE_EXIT'
          SUPPRESS_LANGUAGE_CHECK = SPACE
        IMPORTING
          NEW_MASTER_LANGUAGE     = P_OLD_LANGU
          MODIFICATION_LANGUAGE   = P_MOD_LANGU
          TRANSPORT_KEY           = P_TRKEY
          DEVCLASS                = P_DEVCLASS
        EXCEPTIONS
          CANCELED_IN_CORR        = 1
          OTHERS                  = 2.

      IF SY-SUBRC = 0. " Success
        MOVE: P_DEVCLASS TO V_DEVCLASS.
      ELSE. " For the case that nothing is found!
        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 = P_DEVCLASS.

          MOVE: TADIR-DEVCLASS TO V_DEVCLASS.
        ENDIF.
      ENDIF.
    ENDIF.
*Find SAP Modifactions

    SELECT *
      FROM TADIR
      INTO TABLE JTAB
     WHERE PGMID = 'R3TR'
       AND OBJECT = 'SMOD'
       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.

    FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
    SKIP.
    WRITE:/1 'The application area is:', V_DEVCLASS.
    SKIP.

    IF NOT JTAB[] IS INITIAL.
      WRITE:/(95) SY-ULINE.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      WRITE:/1 SY-VLINE, 2 'Exit Name', 21 SY-VLINE,
      22 'Description', 95 SY-VLINE.
      WRITE:/(95) SY-ULINE.

      LOOP AT JTAB.
        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,
        21 SY-VLINE , 22 MODSAPT-MODTEXT, 95 SY-VLINE.
      ENDLOOP.

      WRITE:/(95) SY-ULINE.
      DESCRIBE TABLE JTAB.
      SKIP.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      WRITE:/ 'No of Exits:', SY-TFILL.
      SKIP.
      WRITE:/(83) SY-ULINE.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      WRITE:/1 SY-VLINE, 2 'Badi Name', 22 SY-VLINE,
      23 'Description', 83 SY-VLINE.
      WRITE:/(83) SY-ULINE.

* select the BAdI Definitions from the tables sxc_exit and sxc_attr
      SELECT T~OBJ_NAME T~DEVCLASS TC~DLVUNIT SX~IMP_NAME SAT~TEXT
        INTO CORRESPONDING FIELDS OF TABLE LT_BADI_LIST
        FROM ( ( ( ( TADIR AS T
       INNER JOIN TDEVC AS TC ON T~DEVCLASS = TC~DEVCLASS )
       INNER JOIN SXC_EXIT AS SX ON SX~EXIT_NAME = T~OBJ_NAME )
       INNER JOIN SXC_ATTR AS SA ON SX~IMP_NAME = SA~IMP_NAME )
       INNER JOIN SXC_ATTRT AS SAT ON SX~IMP_NAME = SAT~IMP_NAME )
       WHERE T~PGMID = 'R3TR'
         AND T~OBJECT = 'SXSD' "means BAdI
         AND T~DEVCLASS = V_DEVCLASS "narrow down seach with Dev.Class
         AND SAT~SPRSL = SY-LANGU.

      SORT LT_BADI_LIST.
      DELETE ADJACENT DUPLICATES FROM LT_BADI_LIST.
* create Ranges
      LOOP AT LT_BADI_LIST INTO LS_BADI_LIST.
        R_BADI-SIGN = 'I' .
        R_BADI-OPTION ='EQ' .
        R_BADI-LOW = LS_BADI_LIST-IMP_NAME.
        R_BADI-HIGH = LS_BADI_LIST-IMP_NAME.
        APPEND R_BADI TO RT_BADI .
      ENDLOOP.
* select the implementations
      SELECT T~OBJ_NAME T~DEVCLASS TC~DLVUNIT
        INTO CORRESPONDING FIELDS OF TABLE LT_BADI_LIST2
        FROM TADIR AS T
       INNER JOIN TDEVC AS TC ON T~DEVCLASS = TC~DEVCLASS
         FOR ALL ENTRIES IN RT_BADI
       WHERE T~OBJ_NAME = RT_BADI-LOW
         AND T~PGMID = 'R3TR'
         AND T~OBJECT = 'SXCI'.

      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE:/(83) SY-ULINE.
      COUNT = '0'.

      LOOP AT LT_BADI_LIST INTO LS_BADI_LIST .
        WRITE:/1 SY-VLINE, 2 LS_BADI_LIST-OBJ_NAME HOTSPOT ON, 22
        SY-VLINE, 23 LS_BADI_LIST-TEXT, 83 SY-VLINE.
        COUNT = COUNT + 1.
      ENDLOOP.

      WRITE:/(83) SY-ULINE.
      DESCRIBE TABLE LS_BADI_LIST.
      SKIP.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      WRITE:/ 'No of BADIs:' , COUNT.
    ELSE.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      WRITE:/(95) 'No User Exit exists'.
    ENDIF.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE:/(95) 'Transaction Code Does Not Exist'.
  ENDIF.
*&---------------------------------------------------------------------*
*& Call SMOD or SE18 to lead the user to the selected exit or badi     *
*&---------------------------------------------------------------------*
AT LINE-SELECTION.

  GET CURSOR FIELD FIELD1.
  IF FIELD1(4) EQ 'JTAB'.
    SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).
    CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
  ELSEIF FIELD1(12) EQ 'LS_BADI_LIST'.
    CALL FUNCTION 'SXO_BADI_SHOW'
      EXPORTING
        EXIT_NAME = SY-LISEL+1(20)
      EXCEPTIONS
        ACTION_CANCELED
        ACCESS_FAILURE
        BADI_NOT_EXIXTING.
  ELSE.

  ENDIF.

 

 

 

 

REPORT Z_FIND_USEREXIT2 NO STANDARD PAGE HEADING.
*&---------------------------------------------------------------------*
*&  Enter the transaction code that you want to search through in order
*&  to find which Standard SAP User Exits exists.
*&
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& 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
         TSTCT.     " Transaction Code Texts

*&---------------------------------------------------------------------*
*& Variables
*&---------------------------------------------------------------------*
DATA : JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE.
DATA : FIELD1(30).
DATA : V_DEVCLASS LIKE TADIR-DEVCLASS.

*&---------------------------------------------------------------------*
*& 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.
SELECTION-SCREEN END OF BLOCK A01.

*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Validate Transaction Code
  SELECT SINGLE *
    FROM TSTC
   WHERE TCODE EQ P_TCODE.
* 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 = 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 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 :/(95) SY-ULINE.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      WRITE:/1 SY-VLINE,
            2 'Exit Name',
            21 SY-VLINE ,
            22 'Description',
            95 SY-VLINE.
      WRITE:/(95) SY-ULINE.

      LOOP AT JTAB.
        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,
                21 SY-VLINE ,
                22 MODSAPT-MODTEXT,
                95 SY-VLINE.
      ENDLOOP.

      WRITE :/(95) SY-ULINE.
      DESCRIBE TABLE JTAB.
      SKIP.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      WRITE :/ 'No of Exits:' , SY-TFILL.
    ELSE.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      WRITE :/(95) 'No User Exit exists'.
    ENDIF.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE :/(95) 'Transaction Code Does Not Exist'.
  ENDIF.

* Take the user to SMOD for the Exit that was selected.
AT LINE-SELECTION.
  GET CURSOR FIELD FIELD1.
  CHECK FIELD1(4) EQ 'JTAB'.
  SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).
  CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

 

分享到:
评论

相关推荐

    SAP T-Code速查手册

    为了便于各类用户高效操作SAP系统,一本详尽的“SAP T-Code速查手册”应运而生,它如同一把钥匙,为SAP R/3系统的最终用户、咨询顾问、技术支持人员和技术开发人员开启了通往系统深处的大门。 二、T-Code:SAP系统...

    SAP ABAP 常用T-CODE

    - **CMOD** (SMOD):增强SAP标准功能。 - **OSS1**:SAP Online Support。 - **S001**:ABAP工作台说明(T-CODE)。 - **SCAT**:Computer Aided Test Tool。 - **SE01**:维护数据元素(同一数据元素在不同客户端中...

    SAP方丈-ABAP-SAP增强应用实例.docx

    我们可以通过T-code:CMOD来实现这个增强。 首先,我们需要在ABAP Workbench中创建一个新的程序。然后,我们可以通过功能退出增加增强语句,如图4所示。双击程序后,我们可以加入以下语句: ```scss if sy-tcode <>...

    sap t code rz11

    标题与描述中的“SAP T Code RZ11”指的是SAP系统中一个特定的事务代码,用于管理和配置SAP GUI Scripting的安全性。在SAP环境中,事务代码是用户执行特定任务或功能的入口点,RZ11主要用于设置和控制与SAP GUI ...

    SAP增强查找工具程序SAP增强工具程序

    根据提供的文件信息,可以看出这是一段与SAP相关的ABAP编程代码片段,主要涉及一个用于查找和展示SAP系统中各种增强(Enhancements)的工具程序。以下将详细解析这段代码所实现的功能及其背后的原理。 ### SAP增强...

    SAP-code.rar_SAP

    这个“SAP-code.rar_SAP”压缩包文件包含的是SAP R/3的事务代码速查手册,这对于学习和理解SAP系统操作至关重要。 事务代码是SAP系统中的核心元素,它是用户与系统交互的入口点。每个事务代码对应一个特定的功能或...

    SAP BW 数据源介绍及增强

    在SAP中,可以使用T-CODE SE12和SE16进行增强。SE12用于修改和扩展提取结构,添加或删除字段,以适应新的报告需求。而SE16则用于管理数据转换,允许用户定制数据处理逻辑,比如数据清洗、计算字段的创建等。 自定义...

    SAP各代增强介绍与查找

    SAP增强是一种关键的技术手段,它允许用户在不修改标准SAP软件的情况下,根据特定的业务需求定制和扩展其功能。以下是对SAP各代增强的详细介绍: 1. **什么是SAP增强** SAP增强是为了适应企业个性化需求,允许用户...

    SAP code 大全

    在此基础上,BAPI(Business Application Programming Interface)技术(1.6.1章节)允许开发者创建自定义接口,增强系统的可扩展性。CA-BFA-WEB则关注Web Basis,讨论如何利用Web技术提升SAP系统的用户界面和远程...

    SAP现金日记帐增强

    1. **执行Transaction Code FBCJ**:首先,需要登录SAP系统并执行事务代码FBCJ来打开现金日记账界面。 2. **加入新字段**:将新总账中新增的字段加入到现金日记账屏幕中。例如,假设需要加入一个名为`ZZCHAN`的新...

    SAP -ABAP绝对的code合集

    "SAP - ABAP绝对的code合集"是一个针对SAP ABAP初学者和进阶者的重要资源,它包含了一系列SAP ABAP编程中的实用代码示例。 ABAP基础知识包括数据类型、变量声明、控制结构(如IF-THEN-ELSE、CASE)、循环(DO-WHILE...

    SAP BASIS Tcode大全

    在SAP系统中,事务码(Transaction Code)是用于访问具体功能和应用的唯一代码。对于从事SAP BASIS运维的工作人员来说,掌握常用的事务码是基本要求。本文将详细介绍在日常运维中可能使用到的SAP BASIS事务码及其...

    sap 增强 badi userexit customerexit

    SAP增强BADI UserExit CustomerExit SAP增强BADI UserExit CustomerExit是SAP系统中的一种扩展机制,通过预留的Form/Subroutine,allowing开发者在系统中添加自己的逻辑。这种机制分为三种类型:User Exits、...

    AWS SAP SAP SAP

    6. **自动化和DevOps**:掌握使用 AWS CodePipeline、CodeBuild 和 CodeDeploy 自动化 SAP 环境的部署和更新,以及如何实施持续集成和持续交付。 通过深入学习这些知识点,IT 专业人员将能够更好地在 AWS 上部署、...

    SAP ECC 6.0 (SAP_APPL 600)

    Delta功能是指在SAP ECC 6.0中新增或改进的功能点,它旨在提升系统性能、增强用户体验及满足特定行业的业务需求。例如,通过引入更先进的算法和数据处理技术,Delta功能可实现更高效的数据管理和分析,帮助企业做出...

    SAP ABAP ScriptForm 中文版本

    ### SAP ABAP ScriptForm 中文版本 #### SAPscript的组成及功能详解 ##### 1.1 SAPscript的组成 SAPscript 是一种用于创建和管理SAP系统中的表单的技术,它由以下五个主要组成部分构成: 1. **编辑器**:负责...

    SAP 打语言包(SMLT)

    ### SAP 打语言包(SMLT)操作指南 #### 一、简介 ...这不仅提升了系统的可用性,还增强了用户体验。务必仔细按照每一步骤操作,避免遗漏任何重要细节,从而确保语言包能够正确无误地安装并正常工作。

    SAP各模板增强用户出口汇总

    1. **定义项目 (T-Code: CMOD)**:创建一个项目来管理所有的增强活动。这不同于PS模块中的项目。 2. **分配增强**:将需要增强的系统功能(Enhancement)分配给该项目。 3. **编辑用户出口对象**:在系统增强中编辑...

    SAP ABAP 1.4.4代码下载

    文件名为"SAP ABAP CODE下载-1.4.4.txt"可能是一个文本文件,其中包含了这些源代码的清单或者链接,供开发者参考和下载。 在实际应用中,SAP ABAP的开发者可能会使用SE80交易码来访问和编辑代码,或者通过ABAP ...

Global site tag (gtag.js) - Google Analytics