You are on page 1of 16

Enhancement Spot

The enhancement spots are used to manage explicit enhancement options. Enhancement spots carry information about the positions at which enhancement options were created. One enhancement spot can manage several enhancement options of a Repository object. Conversely, several enhancement spots can be assigned to one enhancement option. Use You create an explicit enhancement option when processing a Repository object with the relevant tool by creating an enhancement spot element definition at a point where this is possible. This enhancement option can then be called at different points using enhancement spot element calls. The enhancement spot element definition and the corresponding enhancement spot element calls make up the definition of an enhancement option. For example, when editing an ABAP program with the ABAP Editor, you can define explicit enhancement options in the form of the ENHANCEMENT-POINT statement, which also represents the element definition and element call. Each enhancement spot element definition must be assigned to at least one enhancement spot. For this, an enhancement spot element definition is assigned one or more simple enhancement spots, which in turn are assigned to at least one composite enhancement spot. Simple and composite enhancement spots are Repository objects that form a tree-like structure, where the leaves and branches represent simple and composite enhancement spots respectively. A simple enhancement spot is always assigned to exactly one enhancement technology (ABAP source code enhancement or BAdI). Composite enhancement spots are used for the semantic grouping of simple enhancement spots. A composite enhancement spot contains either one or more simple enhancement spots and/or one or more composite enhancement spots of the relevant type. You can use composite enhancement spots to combine simple enhancement spots into meaningful units.
The statement ENHANCEMENT-POINT can either be entered directly or created by choosing Edit Enhancement operations Create enhancement in the Enhancement Builder.

1. I have always used only IMPLICIT enhancement points for my fixes. Is there a specific reason to use EXPLICIT? shoudn't IMPLICIT cover all the scenarios so there is no need to use EXPLICIT ? I have user created an EXPLICIT because it looked quite complicated. 2. when I am creating an IMPLICIT enhancement, i am asked for composite enhancement implementation, although this can be left blank. why is this field not required? and what benefit of creating a composite Enhancement Implementation?

Implementing Implicit Enhancement Options:


1- From within the SAP function module of interest, click on the swirly icon ("Enhance Source Code" button) between the "Other object" and "Check" buttons:

This places you into "change enhancements" mode. To show implicit enhancements spots: 2- Edit -> Enhancement Operations -> Show Implicit Enhancement Options

You will usually find these implicit enhancement options at the beginning and end of function modules, subroutines, includes and methods or the end of structures & private/protected/public section of a local class. In this example I'm choosing the one at the end of the function module:

3- With the implicit enhancement option selected, now create an Enhancment: Edit -> Enhancement Operations -> Create Enhancement

4- Next you choose whether this is a data declaration (static) enhancement or a coding (dynamic) enhancement. Choose "code" (well maybe not...) . At SAPTechEd 2009, they recommended that if your code has any data declarations it should be defined static (Declaration) and not dynamic (Code). This is because data declarations are always static even if they are inside a dynamic enhancement option. Furthermore, you can't place form routines, methods or local classes within a dynamically defined enhancement implementation. I think what is going on here is that dynamic enhancement implementations are surrounded by an "IF" statement at runtime. Data declarations are declared regardless of whether an "IF" statement evaluates to true and subroutines, methods and local classes will not compile within an "IF" statement. Hence all of these should be defined as static (Declaration).

5- Next you select or create your enhancement implementation:

When I created an enhancement implementation from a module pool. It is probably because an existing implementation does not exist for this repository object (SAPFF011) whereas one did exist for the above function module. Name your enhancement according to our programming standards (Z followed by 2 character application area abbreviation).

Recommend that the only code in the actual enhancement be an INCLUDE (e.g., include ZAP_RFP_BLOCK_DELETE_FROM_WF.) This will make future maintenance easier because maintaining INCLUDE is easier and less buggy than maintaining the enhancement. Document the INCLUDE with the exact location(s) from where the enhancement code is called. (e.g., Called from workflow, FBV2 and FV60. The enhancement is in INCLUDE LFBCBFC0, form routine, CHECK_DOCUMENT_TYPE, start of form). This will help in the future if SPAU_ENH notes a conflict that must be manually adjusted. If SAP indicates the INCLUDE you created is called by more than one SAP program (e.g., SAPLF040 & SAPMF05V), this is an indication that there are multiple entry points into the code and you should test all the entry points. There are several reasons for this. The first reason is that each enhancement will only be triggered by a single entry point even though the SAP code is called by multiple entry points. The second reason is that the different entry points might be populating variables with different values. INCLUDE you created called by multiple SAP entry points:

Requires multiple Enhancements: Enhancement called from FBV2 initial screen (SAPMF05V):

Enhancement called from FBV2 Pick List screen (SAPLF040):

Code that makes this single include work for both enhancments each from a different entry point:
* SAPMF05V means it is coming from FBV2 / FBV3 / FBV0 / FBV4 initial screen * RFPUEB00 means it is coming from FBV2 / FBV3 / FBV0 / FBV4 pick list IF sy-cprog = lc_zmit_init_screen. " SAPMF05V l_zmit_bukrs_field = 'RF05V-BUKRS'. l_zmit_belnr_field = 'RF05V-BELNR'. l_zmit_gjahr_field = 'RF05V-GJAHR'. ELSE. l_zmit_bukrs_field = 'BUKRS'. l_zmit_belnr_field = 'BELNR'. l_zmit_gjahr_field = 'GJAHR'. ENDIF. ASSIGN (l_zmit_bukrs_field) TO . ASSIGN (l_zmit_belnr_field) TO . ASSIGN (l_zmit_gjahr_field) TO .

Implement Explicit Enhancement Spot (Implementing SAP supplied Explicit ENHANCEMENT-POINT/SECTION NOT Recommened!):
As for the usage of explicit enhancement points, in general, customers may use explicit points defined by SAP. But SAP cannot guarantee the stability of these points. Moreover, if you implement a point already implemented by a SAP IS, we do not guarantee the order in which these implementations are called.

The following enhancement option types are available in a source code: ENHANCEMENT-POINT to add code - can either be static (for example, additional data declaration) or dynamic (for example, additional coding). You can not trust the sequence of the added code. ENHANCEMENT-SECTION to replace code - can either be static (for example, replace an existing data declaration) or dynamic (for example, replace coding). Note Data declarations are always static, even if they are inside a dynamic enhancement option. Form routines, methods, and local classes cannot be part of dynamic enhancement options/sections. Therefore, it is necessary to place them into static enhancement options/sections. Static enhancement options/sections are marked with STATIC in coding. Dynamic enhancement options/sections do not contain an addition. 1- From BAdI Builder (SE18) associated with Enhancement Spot of interest. 2- Display the SAP Enhancement option 3- Under the tab Enhancement Options, choose enhancement implementation point/section from the List of Enhancement Options & double click

PR: -> Program EX: -> Explicit? FO: -> Form routine SE: -> Section EI -> ?

FU: -> Function Module IC: -> Include TY: -> Type? ME: -> Method? 4- Turn on enhancements with swirling icon

5- Select enhancement name and right click -> Enhancement Implementation -> Create

This creates additional enhancement code at this spot.

Implement Explicit Enhancement Spot that is an Interface (new style BAdI)


Keep in mind that implementing the new style BAdIs (GET/CALL) is Ok but implementing an explicit Enhancement-Point/Section supplied by SAP is not recommended:

https://forums.sdn.sap.com/thread.jspa?threadID=872651&messageID=5453372 "We do not recommend to use existing explicit Enhancement-Points/Sections from SAP. They are needed for industry solutions and can change. So this can result to higher conflict resolution efforts." 1- From BAdI Builder (SE18) associated with Enhancement Spot of interest. 2- Display the SAP Enhancement option 3- Under the Enh. Spot Element Definitions tab select the BAdI definition of interest and click on the people icon above the definition to create BAdI implementation:

Implementing a Classic BAdI


(also see Enhancement Implementations & Spots) When possible avoid implementing Classic BAdIs because they are 40 to 600 times slower than the new BAdIs (Explicit BAdI Enhancements). SE19 (Business Add-Ins - Implementation) Enter a pre-existing Classic BAdI definition into the BAdI Name and "Create Impl."

Provide an implementation name

Provide implementation short text.

Go to Interface tab and choose method of interest and double click which will take you to method's code where you can place your code:

Defining Enhancement Options


Generally, you will be implementing enhancement options that have been defined by SAP but occassionally there is a need to create one that you will then implement. (Wasn't able to convert mods that requied explicit enhancement spots, probably because of authorizaitons but didn't seem worth pursuing. If mod requires replacing or deleting SAP code or can not be placed in an implicit enhancement location, not worth turning into an explicit enhancement) In the nomenclature of the enhancement concept, an enhancement option represents (in an ABAP source code) both the enhancement spot element definition, and the enhancement spot element call. A source code plug-in, however, refers to an enhancement implementation element of a (simple) enhancement implementation.

Call a Simple Enhancement Spot ENHANCEMENT-SECTION (Replace code)


If you need to replace SAP code, through the modification assistant insert the code for an enhancement section: ENHANCEMENT-SECTION z_name_of_enhancement_section SPOTS zes_name_simple_enh_spot. SAP code that is being replaced... END-ENHANCEMENT-SECTION. z_name_of_enhancement_section is the Enhancement ID (i.e., the name of the Enhancement Option). It must be no longer than 30 characters. SAP's naming convention is to have the last 3 characters be _01, _02, etc. zes_name_simple_enh_spot is the name of the enhancement spot that the ID is assigned to.

Activate:

A simple Enhancement Spot for an Enhancement Section was created:

After pretty printer, you can not modify this enhancement option via normal editing in the ABAP editor. You can click on the Enhancement ID (e.g., z_name_of_enhancement_section) and using the context menu select Enhancements -> Undo which will remove the option and any implementation that has been created. Enhancements -> Change option: It takes you to a popup entitled "Create Enhancement Option" which seems to allow you to either change the Enhancement Spot your option is assigned to or to create additional assignments. Notice that even though this particular option is a SECTION and not a POINT, this popup indicates a POINT and does not allow you to change this designation.

When I created a 2nd enhancment section and assigned it to the same enhancement spot (i.e., zes_name_simple_enh_spot), it created a 2nd enhancement option within the same Simple Enhancement Spot. So a Simple Enhancement Spot can contain multiple options. Follow instructions to implement these Explicit Enhancement options. When I selected to create the 2nd implementation I was given the opportunity to choose the first implementation or create a new implementation. I chose to create a new one. Final picture:

What I don't know how to do is use the switching mechanism. It looks like there is a swich available on the Spot level and on the implementation level. Neither are modifiable in SF2. Ahhh.... I learned how to use the switching mechanism. It is done at the Package Level. I ended up not using either the composite enhancement spot nor the simple enhancement spot that I created below. Above when I tried to name my simple enhancement spot the ZTESTBADI that I created below via SE80, I got an error message indicating this enhancement spot was in another object.

Create an Enhancment Spot for the Package (i.e., Development Class) of interest
1. Start the Object Navigator (SE80) and choose Package and display 2. Create a composite enhancement spot via the context menu associated with the Package Name.

3. Choose Create -> Enhancement -> Composite Enhancement Spot

4. A dialog appears - Specify a name and short description

5. Activate (I've run into authorization issue so stop for now)

You might also like