BADI using Enhancement Framework

解码SAP BADI设计哲学:从CMOD到Enhancement Framework的演进之路 本文深入解析SAP BADI设计哲学,从传统CMOD到现代Enhancement Framework的技术演进。重点探讨BADI在SAP BW场景中的核心机制与实战应用,包括过滤器设计、多实现管理及性能优化技巧,为ABAP开发者提供从理论到实践的完整指导。 阅读详情

BADI using Enhancement Framework
Neeraj Batra
Business Card
Company: Infosys Technologies Limited
Posted on Mar. 18, 2009 06:27 AM in ABAP

Introduction

During the course of the following document; the reader can understand how the BAdI concept fits in to the new Enhancement Framework. We will create a BAdI definition in the first part and in the later part we will implement the BAdI. Basic knowledge about the new enhancement framework will help in understanding this document better.

Who creates the BAdI definition

Please understand that most of us (Technical SAP – ABAP) will seldom have the requirement to create a BAdI definition. Unless we are working on a ‘product development’ in collaboration with SAP itself; we will be only dealing with the implementation part. Though I mention above that we will seldom be defining a BAdI; it is a very important to understand the BAdI declaration; to appreciate the concept of Enhancement Framework as a whole. 

 --- BAdI definition is part of product development; majorly.

 

The requirement

 

Ok let us assume we are working on a SAP product which has a requirement to perform currency conversion (wrt USD) based on the country provided by the user. 

Let us write a program for it.

image

The program simply has a parameter country. To output the converted value; I would require the conversion rate.  And I leave it to the customer to enhance the application and provide the conversion rate. 

This is where I use a BAdI.

 

First step -> creating the Enhancement Spot!! 

People familiar with source code enhancements can appreciate the fact that the first step for an enhancement implementation is an Enhancement Spot. Same is the case here; we need to create an enhancement spot which will act as a container for the BAdI definition 

So for the time being let us forget the ABAP report and move to SE80; to create the container (Enhancement Spot).

Select Local Objects -> Enhancements -> Enhancement Spots -> Create (right click).  

 --- Enhancement spot acts as a container for a BAdI definition!!   

image"

Note – If you questioned the usage of local objects in the previous step; please be aware that; strangely; the section ‘Enhancement Info Systems’ in SE80 does not let you create a new enhancement spot. The ‘Local’ issue is however taken care of; when upon saving; we are prompted to enter the package. 

Create a new BAdI definition as shown below.

 

image"

image

Multiple Use

Currently; in our requirement we are performing only one operation on the amount based on the conversion rate. However; say in China; we want to perform another operation ‘Enhance Currency’; we would be required to use the option ‘Multiple Use’. Please be aware that the order of occurrence of the various implementations of a multiple use BAdI cannot be ascertained!!

--- Multiple Use -> Series of operations (BAdI implementations); not following specific order of occurrence though!!  

For the current requirement however we will be content without the multiple use option.

Interface

The next step is to define an interface. Just pull the arrow down in the left side section and mention the interface name and press the ‘change interface’ button.

image

 --- ‘Interface’ differentiates a BAdI from explicit  enhancement option!!

image

The screen above is what differentiates an explicit enhancement option from a BAdI. BAdI is like a controlled explicit enhancement point. Controlled; why? Because; the developer decides the parameters that the implementer will have access to.

 

Whereas; in explicit enhancement option the implementer can play around with all the variables of the source code; often inviting unplanned behavior of the system. 

 

In other words BAdI is definitely less dangerous than explicit enhancement option!! 

 

The above might lead you in to thinking that the developer should always follow the best path and create an option for a BAdI; why give the option of explicit enhancement points/sections. BUT; there are numerous cases wherein the developer does not know which variable the user might want to use and in what way (yes, it happens!!) This is where explicit enhancement options are inevitable. 

 

Also, of course there are cases wherein there are no parameters required and no operations to be performed on them; but simply a piece of code needs to be added to the source code -> Explicit Enhancement Option is the answer; no use of BAdI here !! 

 

Create a method ‘Conversion’ as shown below.

image

Filter -> Remember the ‘country-specific’ functionality!!

The conversion factor would vary with the country the user enters; therefore we require different implementations to be called based on the ‘filter’ country. The option of providing the scope of a filter lies with the developer defining the BAdI. (Then only it will be available to the implementer!!) The following screenshot shows how to do the same; go to BAdI Definition -> Right Click -> Create filter

image

Enter the Filter Name and the Filter Type. In this case; the filter type would be Character. 

--- Filter facilitates usage of multiple implementations in a single usage  BAdI (Only one is executed though!!)

image

This is all that is required to provide the option of a filter!!

Summary till now!!

We have created an Enhancement Spot which holds the BAdI definition. Our BAdI definition defines the parameter that the implementers can pass/retrieve/change to the method in the BAdI. Also, we have left an option of a Character-Type filter.

Back to the report… 

We still do not have the link to the BAdI in the source code of the report. The following coding does just that!!

 

image

What happened? 

If you thought the job was over for the developer; please look at the following dump. The system raises an exception ‘CX_BADI_NOT_IMPLEMENTED’ if it does not find any implementations for the BAdI. In our case; we are still developing the application; hence the obvious dump.

image

 --- Fallback Class is useful in case no active implementation exists!!

The solution for the Dump -> Fallback Class

Fallback Class is the savior when there is no active implementation for the BAdI definition. It the current scenario; it can be imagined as the case wherein the user wants to convert USD to USD itself!! To create the fallback class; just got to the BAdI definition screen and click check-box ‘Call fallback if no implementation is executed’. Enter the class name and press enter.

image

In the method of the fallback class we will pass the amount as the answer itself.

That is it!!

 

image

 

This completes the BAdI Definition part of the document!! 

And now the implementation… 

Well the product development is over; now I am the customer of SAP; and want to use the hook provided above to fulfill my specific requirement. So; let us implement the BAdI now!!  

--- Implementation is post product development; of course!! 

Enter the Enhancement Spot via SE80; of course in Display mode (SAP created it!!). Right click on the BAdI definition and click Create BAdI definition. 

image

You will be prompted to enter the implementing class for the BAdI implementation created in the previous step. Here; you can use the example class to make life easier (The fallback class we created is an example of ‘Example Class’).

image

 image

Enter the desired code in the method of the implementing class; for our requirement; I am using conversion factor as 49 (Rupee depreciation / appreciation a separate issue!!)

Activate.

image

 

Filter value: We are still to add the filter value to this implementation. Go to the implementation and add the filter.

 

image

 

 

Similarly, create n implementations for n countries; giving the filter value as desired. Here; I created one for UK.

 

Let us test the report… 

Case 1 Data: -          Country IN; Amount 100

image

 

Case 2   Data:-           Country UK, Amount 100

 

image

 

A freebie in The End… 

Though not related; I will demonstrate creating an explicit enhancement point in the source code as a freebie for this document; yipee!! 

Simply go to the report Right Click -> Enhancements  -> Create

image

Enter the Enhancement Point and Enhancement Spot.

image

That is all. Yes; easier than BAdI definition but definitely more dangerous!!

Conclusion 

Hopefully the document through the simple example clears the BAI concept; both from definition and implementation point of view.

SAP 四代增强方式和Enhancement查找方法 第一代:基于源码增强(子过程subroutine) 第一代增强基于源代码,是SAP提供的一个空代码的子过程。在这个子过程中用户可以添加自己的代码,控制自己的需求。这类增强集中在一些文件名倒数第二个字符为Z的包含程序中。 一般是以UserExit_打头的子过程,因此形象地称其为用户出口。 用户出口Include在SAP标准程序的源代码里,可以说是源代码的一部分,更改用户出口就相当于更改SAP标准程序,是需要在SAP Service MarketPlace里申请对象键(Access Key)才能更改,不需 阅读详情

相关推荐

SAP增强Enhancement

第一代:基于源码增强(子过程subroutine) 第一代增强基于源代码,是SAP提供的一个空代码的子过程。在这个子过程中用户可以添加自己的代码,控制自己的需求。这类增强集中在一些文件名倒数第二个字符为Z的包含程序中。 一般是以UserExit_打头的子过程,因此形象地称其为用户出口。 用户出口Include在SAP标准程序的源代码里,可以说是源代码...

anpenshi6285的博客 1182

2020-11-28

ABAP EXCEPTION CX_ROOT | |–CX_STATIC_CHECK | |–CX_DYNAMIC_CHECK | | | |–CX_SY_ARITHMETIC_ERROR //运算 ‘&OPERATION&’ 时发生算术错误 | | | | | |–CX_SY_ZERODIVIDE //除数为零 | | | | | |–CX_SY_ARITHMETIC_OVERFLOW //操作 &OPERATION&am

gqyuan8888的博客 1306

sap 一代增强_SAP增强Enhancement

第一代:基于源码增强(子过程subroutine)第一代增强基于源代码,是SAP提供的一个空代码的子过程。在这个子过程中用户可以添加自己的代码,控制自己的需求。这类增强集中在一些文件名倒数第二个字符为Z的包含程序中。 一般是以UserExit_打头的子过程,因此形象地称其为用户出口。用户出口Include在SAP标准程序的源代码里,可以说是源代码的一部分,更改用户出口就相当于更改SAP标准程序,是...

weixin_39958025的博客 641

j3rflvmobvedh 新俄罗斯报表配置字段

取凭证和计算各字段值位置,通过BADI J_3RMOBVEDH实现,在实施类CL_J_3RMOBVEDH_BADI的方法IF_J_3RMOBVEDH_BADI~CALCULATE_TURNOVERS中 可以看到销售出货数量通过 TURNTYP 判断的 ( case ...

盈于心胸,充塞天地 1万+

SAP二代增强实战:BAdI与隐式增强点应用指南

在ERP系统定制开发中,系统扩展机制是连接标准功能与个性化业务需求的关键桥梁。其核心原理在于通过预定义接口与钩子,在不修改底层源代码的前提下实现功能扩展,这确保了系统的可维护性与升级兼容性。从技术价值看,这种结构化扩展方式大幅降低了定制开发与标准升级的冲突风险,提升了代码的模块化和可复用性。在实际应用场景中,企业常需在物料管理、销售订单处理等核心业务流程中嵌入特定校验规则或业务逻辑。本文聚焦的SAP二代增强框架,正是通过BAdI和隐式增强点等核心组件,为这类需求提供了标准化解决方案。其中,BAdI作为面向对

weixin_29050513的博客 239

SAP的一代、二代、三代、四代增强分别是什么?你还听说过VOFM例程、BTE增强没?

按SAP系统技术发展来分,SAP增强包括第一代、第二代、第三代、第四代增强,另外还有VOFM例程、BTE等

saplakes的博客 1994

BADI的工作原理(转自吕中奇的belong)

Class是object的抽象描述,object只是在程序运行时才能存在。Object是由class描述的,并包含两个层次,inner layer和outer layer。Object的public component就是这个object的interface。Oo的主要目的就是为了保证object本身状态的consistency。Object的attributes一般是internal的,只能被它

duanyu9879的专栏 2078

用 BAdI 打造可控、可扩展、可切换的增强体系:从 Enhancement Framework 到 GET BADI / CALL BADI 的工程化实践

本文深入解析SAP增强框架中的BAdI技术体系,揭示其作为增强体系主干的核心价值。BAdI通过结构化方式将增强点、实现类和过滤器串联成完整链路,支持面向对象编程模式,相比传统增强方式更具工程化优势。文章详细剖析BAdI的三大组成部分:接口契约、过滤机制和实现类,并重点阐述四个关键配置开关(单/多实现、回退类、上下文绑定和开关框架)对系统维护性的影响。通过税率计算、订单定价等实际案例,说明BAdI在复杂业务场景中的应用价值,并解读GET BADI和CALL BADI语句的运行时机制,为SAP项目实施提供技术指

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 563

SAP 增强有关enhancement framework

2005年NetWeaver 7.0诞生,它的一个部分,就是enhancement framework。从2005年开始SAP的增强就更加现代化。2005年之前的增强是什么样的呢?如下图 2005年之后,出现了netweaver 7.0之后我现在也没有很搞懂2005年以后的状况,但是后面这篇文章很有启发:linknetweaver7.0之前我们可以随意自...

weixin_34209406的博客 296

SAP-ABAP:SAP第二代增强之隐式增强(Implicit Enhancements)和Enhancement Framework 的详细解析

第二代增强技术(隐式增强、Enhancement Framework)与 BADI 结合,提供了从简单代码插入到复杂业务逻辑扩展的完整解决方案。Enhancement Framework 是 SAP NetWeaver 7.0 引入的统一增强管理框架,整合了 BADI、隐式增强、Enhancement Spots 等多种技术,提供更结构化的增强管理方式。隐式增强是 SAP Enhancement Framework 的核心技术之一,允许开发者在 SAP 标准程序、函数组、类或接口的。

baidu_35680696的博客 2417

在 Enhancement Framework 中雕刻扩展契机:ABAP BAdI Definition 全景解析与实战范例

把 SAP 标准代码的可扩展点正式对象化,使客户化需求与核心升级解耦。在 Enhancement Framework 的护航下,开发者能够通过接口、过滤器与多用排序等机制精细控制增强行为,同时维持系统的向前兼容。掌握这些概念并亲手实现示例后,便能在任何模块中快速定位并扩展合适的BAdI,为企业业务创新搭建稳定而灵活的技术底座。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 362

123. SAP ABAP 显式增强技术之 New BAdI 的技术原理介绍

New BAdI 是基于 Classic BAdI 而言的,Classic BAdI 处理逻辑里,ABAP 系统基于 BAdI 增强定义去检索是否存在对应的 BAdI 增强实现,这个逻辑是在 ABAP 应用层完成的。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 889

099、增强(Enhancement)基础

上个月排查一个采购订单的审批逻辑,用户报“明明打了勾,保存后勾没了”。我直接SE38进程序,断点打在PBO,勾选状态一切正常。再往下走,PAI里有个函数叫ME_MESSAGE_SCHEINE_CHECK,看着眼熟,但总觉得哪里不对。一查——这个函数是SAP标准的,但被人用“增强”改过,里面有一段自定义代码,把某个字段的值在特定条件下重置了。这就是典型的“标准程序里看不见的代码”。你翻遍源码都找不到这段逻辑,它躲在增强里。今天就把增强这层窗户纸捅破,别像我当年那样,对着一个不存在的字段值查了三个小时。先搞明白

z534437748的博客 14

对于增强的理解反驳江正军博客

反驳需不需要资格?需要,但是你江正军又不是SAP的作者,也是个用户而已。17.4 第四代增强这部分SAP的PA教材,从来没有出现过汉语:第X代增强的字眼,或者 fourth generation enhancement 的字眼。有图有真相:sap help中没有这个字眼,PA教材中也没有这个字眼,你自己造词,你好意思么?请中国说的abaper不要再说什么...

weixin_33722405的博客 795

SAP-ABAP:SAP第二代增强之BADI详解

第二代增强(BADI)是 SAP 扩展标准功能的核心技术,适用于需要高灵活性和多实例支持的场景。对于复杂需求,可进一步探索第三代增强技术(如。是 SAP 第二代增强的核心技术,基于面向对象(ABAP OO)的设计理念。它允许开发者在不修改 SAP 标准代码的情况下,通过实现预定义的接口(Interface)来扩展或修改标准业务逻辑。SAP 的第二代增强(User Exits)是 SAP 系统中用于扩展标准功能的重要技术手段,属于。第二代增强相比第一代(如函数模块出口)更加灵活和面向对象,主要通过。

baidu_35680696的博客 1493

把 ENHANCEMENT-POINT 用到极致:动态开关、STATIC 声明增强与 INCLUDE BOUND 的工程化玩法

摘要:SAP ABAP Enhancement Framework 中的 ENHANCEMENT-POINT 是实现无修改标准代码扩展的关键技术。文章剖析了该语句的核心价值:既能保持标准代码可升级性,又能灵活插入客户化逻辑。重点解析了其语法设计如何解决工程实践中的三大痛点:通过 enh_id 确保增强点唯一性,利用 SPOTS 实现领域治理,借助 STATIC 和 INCLUDE BOUND 分别支持声明区增强和include复用场景。特别强调动态增强与静态增强的本质区别:生成期插入不等于运行期执行,Swi

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1万+

让 OAuth 2.0 Client Enhancement 的参数值只服务于正确的 Service Provider Type

摘要: 在AS ABAP配置OAuth 2.0 Client Enhancement时,最容易被忽视的是BAdI实现中的Filter Val.字段。该过滤值若配置错误,会导致自定义参数无法正确关联到目标Service Provider Type,甚至错误暴露给其他类型。SAP通过Service Provider Type区分不同OAuth服务提供方的配置需求,自定义类型(如Z*)需配合BAdI实现扩展。关键步骤是为每个BAdI实现设置Filter Combination,在Value 1中填入对应的Serv

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1041

计算机视觉之姿态识别(原理+代码实操)

计算机视觉中的姿态识别原理+模型介绍,同时通过代码实操简单的演示基于mediapipe的单人姿态识别。

输出既学习 3万+
上一篇: Smartform中文乱码问题
下一篇: ALE,IDOC
Conworld
博客等级 码龄25年 3粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值