UserExit

作者:郑德鼎 约 28 分钟阅读 更新日期:2026-07-18 新发布 标签:PP, 生产计划, ABAP, FI, CO, SD, 财务

Enhancement Concept

Text…

1

SAP delivers its software with full source code. In a way, it can be considered as an open source system. SAP customers modified the source code to implement unavoidable logic extensions. The concept of enhancements was born as an attempt to make altering source code more controllable, while retaining considerable freedom for the customer in tailoring unique and business-specific program logic into an existing system.

The available enhancement techniques provided by SAP allow the customer to couple up custom program code with the system. At the same time, these hooks are under SAP ERP control, which makes it possible for the system manufacturer to remain responsible for the whole system’s behavior. 1、SAP增强从用途来说分:A、数据元素增强SE11;B、菜单增强、C、屏幕增强;D、功能增强;

2、SAP增强从实现方式来说分:A 、增强嵌入标准程序中 SD SAPMV45A;B 、 (SMOD、CMOD);C、(BADI);D、(BTE);E、 Implicit Enhancements

3、其他相关增强:A、财务模块常用的替代和验证;B、销售模块常用的例程等 VOFM;

1

Enhancement Types

Text…

2

1. Customer Enhancements (CMOD/SMOD)

Customer enhancements (also known as customer modifications) are the oldest type of enhancement tools available in SAP (the earliest online help for SAP R/3 3.0A Function Module Exit Menu Exit Customer Exit Subscreen

The main drawback of customer exits is that they do not comply with the publishand-subscribe (P&S) paradigm. This means that you can only define a single include for the whole logic, which can potentially be a problem if more than one developer’s work is on the same task involving that particular customer exit. However, there is a workaround for this.

2. Business Transaction Events (BTE) FIBF

A Business Transaction Event (BTE) (also known as Open FI or FI Business Framework)

SAP distinguishes two categories of such callbacks: business transaction events and business transaction event processes. SAP internal This area includes the entire configuration that SAP delivers with the installation. Partner This configuration area belongs to SAP’s software development partner that is developing its own add-on or application component. Customer This area belongs to each end-client/business that is developing application extensions for its own needs.

3. Business Add-In (BAdI) (SE18/SE19)

A business add-in (BAdI) is an object-oriented enhancement tool introduced in SAP R/3 4.6c together with ABAP objects. Generally you can subscribe more than one ABAP class to the same definition.

A BAdI can be marked as SAP internal to prevent a customer from implementing the BAdI.

A BAdI actually defines a global object-oriented interface, and the process of BAdI implementation is the creation of an ABAP class implementing that interface.

A BAdI runtime framework then selects the activated implementations and runs corresponding class methods. There are two flavors of BAdIs available: classic and kernel-based.

4. Explicit(显式) and Implicit(隐试) Enhancements SAP introduced the implicit enhancement concept in SAP NetWeaver 7.0 together with the new Enhancement Framework. Using this option, you can modify virtually any standard source code without requesting a modification key. However, there are some restrictions. For example, you can’t enhance dynpro screens and system programs (those with Program status = “S”). Additionally, an implicit enhancement can’t be implanted into an arbitrary source code place; they are allowed only at the beginning or at the end of a programming module (function, subroutine, or class method), class declaration sections, structure declarations, and some other places. Despite these restrictions, you can almost completely redefine the logic of virtually any given standard function.

2

1. Customer Enhancements (CMOD/SMOD)

Text…

3

3

1. Finding Customer Enhancements (CMOD/SMOD)

Text…

4

4

Passive search method:

1. Find the program name for transaction

Go to attribute for the program and get the Package

Go to Transaction SMOD -> Utilities -> Find

2. Search user-exit in SPRO

Active search method:

The most effective way of finding a customer exit for a particular transaction is by placing a generic breakpoint. First, you have to enter debugging mode via the /H system command, add a breakpoint at the ABAP statement CALL CUSTOMER-FUNCTION, run the investigated transaction, and then wait to see if the breakpoint will be hit. In the Debugger (both old and new), you select the menu path Breakpoints • Breakpoint at • Breakpoint at statement. You then enter the statement in the ABAP Cmnds tab, as shown in Figure

The trouble with this method is that sometimes SAP calls customer exits directly using CALL FUNCTION. But here you can use an additional breakpoint at function module MODX_FUNCTION_ACTIVE_CHECK. This function module checks(tfdir) if a particular customer exit function is activated and thus should always be called before the direct call of the customer exit.

You can also do a Google search for “SAP find user exit program” to find a number of publicly available ABAP utility reports for locating user exits.

1. Finding Customer Enhancements (CMOD/SMOD)

Text…

5

5

Search all active user exit:

TFDIR

2. Business Transaction Events (BTE) FIBF

Text…

6

6

SAP distinguishes two categories of such callbacks: business transaction events and business transaction event processes.

A BTE notifies its subscribers of a particular phase or situation during an application run. Event subscribers are not supposed to change the application data. In practice, however, SAP allows data changing in many BTEs. The full directory of BTEs is stored in configuration table TBE01.

A BTE process also notifies subscribers of a particular situation in an application, but unlike in BTEs, a subscriber can or is even expected to change the supplied data. The BTE process has more sophisticated configuration options: It can be reserved only to SAP internal developments, and it has a call mode, allowing multiple or single subscribers to run. In addition, the BTE process has a default function name in its configuration, which is executed if none of the configured subscriptions are found. The full directory of BTE processes is stored in configuration table TPS01.

2. Business Transaction Events (BTE) FIBF

Text…

7

7

Partner identification is an arbitrary character code that serves as a grouping key for BTE subscriber functions. As with the SAP application, the partner code has its own activation flag, which affects all BTE subscribers assigned to it. The partner identification codes are maintained in Table TBE12.

Products Product code is another subscriber grouping key. There are two kinds of products: products for partners and products for customers. These products are accessible through the FIBF menu via menu path Settings • Product.

Partner Products A partner product differs from a customer product because of the activation technique. With a partner product, you use a list of active products instead of checkboxes

Customer Products The customer products are given in a simple list with product code, activation flags, description, and an RFC destination name.

2. Finding Business Transaction Events (BTE) FIBF

Text…

8

8

As a passive tool for searching BTEs or processes, you can use the BTE Information System accessible in Transaction FIBF via the following menus: Environment • Info system (P/S) Environment • Info system (Processes) A more effective way of finding a BTE is placing a breakpoint into internal BTE function modules and running an SAP transaction or report of your particular interest. When BTE is involved, the SAP system always calls function BF_FUNCTIONS_READ for finding events and PC_FUNCTIONS_READ for processes. Thus, breakpoints in these function modules can discover the major part of available BTE exits.

There is a problem with debugging, however, because it doesn’t always give you 100% accurate results. It isn’t always possible to examine all combinations of parameter/system configuration combinations that lead to a BTE call.

3. Business Add-In (BAdI) (SE18/SE19)

Text…

9

9

Classic BAdI The classic BAdI runtime framework is implemented in the special global class CL_EXITHANDLER. To instantiate a BAdI definition, the static method GET_INSTANCE of the class CL_EXITHANDLER is used. As a result, it returns a runtime reference to the interface of the corresponding BAdI definition. Kernel-Based BAdI The new statement GET BADI is used to instantiate a kernel-based BAdI definition, and the CALL BADI statement is used to call the BAdI interface method.

3. Finding Business Add-In (BAdI) (SE18/SE19)

Text…

10

10

As with other enhancement tools, the Workbench Information System is always available as a passive search method.

SPRO查看Business Add-Ins for xxxx子项。 SE80->Repository Browser->Package->[开发类名]->Enhancements ->Classic BAdIs (Def.)

The active method is using generic breakpoints: Defining breakpoints at the CL_EXITHANDLER=>GET_INSTANCE method can find a classic BAdI, or defining a breakpoint at a GET BADI statement can find a kernel-based BAdI.

SE24查看CL_EXITHANDLER类的GET_INSTANCE方法,在 “CALL METHOD  cl_exithandler=>get_class_name_by_interface”设置断点,运行事务,DEBUG查看EXIT_NAME的值。

ST05跟踪事务码,显示Trace后查找“V_EXT_IMP”和“V_EXT_ACT”;查找以“IF_EX_”开头的字符串,该字符串为接口名,“IF_EX_”后即为BADi名。

SE37查看SXV_GET_CLIF_BY_NAME,设置断点,运行事务,DEBUG查看NAME的值。

4. Explicit(显式) and Implicit(隐试) Enhancements

Text…

11

11

As of NetWeaver 7.0, SAP have also started to provide Explicit Enhancements. To find an explicit enhancement in a program, search for the string ENHANCEMENT-POINT in the ABAP program:

Text…

12

12

4. Explicit(显式) and Implicit(隐试) Enhancements

Text…

13

13

4. Explicit(显式) and Implicit(隐试) Enhancements

Implicit enhancement are provided in specific areas of standard source code:

1. At the end of the programs ( reports, includes, function pools, module pools)

2. At the begin and end of subroutine forms.

3. At the end of the functional module

4. At the end of all visibilities areas

In this case you do not need to create and enhancement spot. You directly put your cursor on the enhancement option and create your implementations by right click.

Explicit enhancement: It can be anywhere in your source code(Z program). You need to explicitly have a enhancement point. It is of two types:

1. Enhancement spot : It is the point where you can add your code. It can have multiple implementations. All the implementations can active at a time but the sequence of executions of the implementations can be anything.

2. enhancement section : If you want to execute your own code instead of some portion standard code. Only the active implementation is execute. Only one implementation is active at a time.

Text…

14

14

4. Explicit(显式) and Implicit(隐试) Enhancements

ENHANCEMENT-POINT是在程序中直接插入代码,其概念与BADI的USER_EXIT类似,标准程序预留了部分已定义好的增强点可以让ABAP做插入代码来实现这个增强,增强选项一定是系统预留下来的,如果没有增强选项则该处不可做增强,但是不能做屏幕和菜单增强。

其最大的优势在于方便,可以使用程序中已定义的变量,不像BTE和USER_EXIT中只能使用函数接口传过来看参数。

一般增强途径: 1.         DEBUG标准程序找到需要增强的位置,点EDIT-> ENHANCEMENT OPERATIONS->SHOW IMPLICIT ENHANCEMENT OPTIONS查看是否有预留增强选项。(标准程序不能自己创建enhancement option ,只能使用系统预留的) 2.         查找预留的ENHANCEMENT-POINT,点EDIT-> ENHANCEMENT OPERATIONS->Create Enhancement

DRP     ZDDTEST DC      /REX/R_CA_FIND_USEREXITS     Z_FIND_USEREXIT UBK    ZVE_FIND_USER_EXIT_BADI        To find User Exit and Badi UBK modification control sample Function module      MRM_INVOICE_POST CALL FUNCTION '/RB04/YBF_CHECK_MODIF' check table /RB04/YBF_MODIF

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「UserExit.pptx」整理生成,仅用于内部技术分享与学习交流。