AB1012 - Enhancements, Exits and BADI's
Enhancements, Exits and BADI's
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
Enhancements, Exits and BADI's
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
Introduction
EXIT s are nothing but the R/3 Enhancements which allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications.
Introduction
Purpose
To introduce the techniques of enhancement in standard SAP system. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.
Introduction
Use
When you add new functionality to your SAP System using SAP’s exits, you do not alter the source code of standard SAP programs in any way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but exist separately from SAP’s standard software package.
When you add new functionality to your SAP System using SAP’s exits, your objects (called customer objects) must adhere to strict naming conventions. When it comes time to upgrade a to a new software release, customer objects’ names ensure that they will not be affected by any changes or new additions to the standard software package.
Introduction
Challenges
1
3
4
2
Enhancements, Exits and BADI's
1
PrepareMe
2
Syntax description
3
Demonstration
4
Exercises
5
HelpMe
ABAP DICTIONARY
Table Enhancements: There are two ways that you can add additional fields to tables without modifying your system.
ABAP DICTIONARY
Field Exits:
Field exits take you from a screen field with a data element reference to a function module. Field exits can be either global or local.
ABAP DICTIONARY
Text Enhancements:
SAP Application Enhancement
Customer Enhancement Projects
Customer Exits
Implementation of Enhancement in Customer System
Creating Customer Enhancement Projects
Assigning SAP Enhancement to customer projects
Editing Components
Activating Enhancement Projects
Business Transaction Events
It is also called as Open FI enhancement technique which is based on the following principle:�
Enhancement Framework
Multilayer Support
Enhancement Spots
Enhancement Implementations
Composite Enhancement Spots
Composite Enhancement Implementation
Composite Enhancement Implementation
Enhancement Relations
Source Code Enhancement
Features of explicit & Implicit enhancement options�
Difference: Explicit and Implicit Option
Explicit Enhancement Options
Implicit Enhancement Options
Enhancement Type
Functional Module Enhancement
Class/Interface Enhancement
Enhancements, Exits and BADI's
1
PrepareMe
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
User Exits
Demonstration
Function Module Exits
Demonstration
Menu Exits
Demonstration
Screen Exits
Demonstration
Field Exits – It is triggered at field level.
It is attached at data element
Specific to one screen only or to all the screen where field appears.
Field exit is not allowed in SAP version 4.7 and above .
Example with screen shots for consultants working in
SAP V 4.6 below version.
Business Add-Ins (BAdI)
What are BAdIs?
Note: In the following slides, Definitions are created so as to understand the method of BAdI definition & for example purpose. As stated above this is the role of Enhancement Option-Provider.
Classic BAdIs already exist since SAP Release 4.6
BAdIs have been Re-implemented in ECC7.0 under the new Enhancement Framework & Switch Framework
Classic BAdIs
BAdI Class (Proxy Class)
Uncheck the ‘Multiple Use’ checkbox. We want to allow only one implementation.
Function Code Enhancements
Screen Enhancements
SE18: BAdI Definition
Classic BAdIs
Double Click on the Interface Name to define methods, parameters, exceptions for that interface
Class Builder Screen will open up.
Classic BAdIs
Add a Method & specify it as Instance Method
Click on Parameters to add Importing / Exporting Parameters
Click on ‘Exceptions’ to define exceptions that will be handled
Classic BAdIs
Add any Exception. For Class-based exceptions check the ‘Exception Classes’ option
Add an Event Name
Add an Event Handler Method
Adding event handling & exception(s) is not a necessary step…
Classic BAdIs
Save and activate the BAdI definition!
BADI Implementation
BAdI Implementation (SE19)
Double Click on the Method to modify the Method code (Class Builder)
SE19: BAdI Implementation
BADI Implementation
Save and activate the BAdI implementation!
Using the BAdI…(Calling the BAdI)
Execute the Report Program.
Implementation for SAP provided BAdI…
Roles: (BADI Definition & Implementation)
BAdI as a ‘controlled’ Enhancement Option:
Steps:
BAdI Implementation
Create Material using MM01. Copy from existing Material.
Select the required views.
BAdI Implementation
Enter mandatory data and click on Save.
Check the Exit Name ‘BADI_MATERIAL_CHECK’. This is the BAdI we are going to implement.
Implementing the BAdI ‘BADI_MATERIAL_CHECK’
Go to SE18 & check the BAdI definition (Methods)
We will be using the ‘CHECK_DATA’ method. Double Click to see the Method Parameters.
Implementing BADI
Go to SE19. Specify a name for the BAdI Implementation.
Enter the Definition Name.
Double-click the method ‘CHECK_DATA’ to enter the source code
Implementing BADI
Enter code inside the ‘Method…End Method’
We are only showing an message in this case; if division in ‘Basic Data’ tab of Material Creation is not entered.
The structure CMARA is defined as ‘Exporting Parameter’. Data can be modified using this.
BAdI Implementation
Activate the Implementation
Testing the BAdI
MM01 / MM02 and create / change material and save. On clicking Save, our BADI will trigger.
Testing the BAdI implementation (BADI_MATERIAL_CHECK)
Message is displayed (Division not entered)
BAdIs…in the new Enhancement Framework (ECC 6.0)
Usage of old (classic) BAdIs versus New BAdIs…
Enhancement Spot as a container for BAdI…
New BAdIs
Create a new Enhancement Spot
Defining & Implementing the new BAdI
Create BAdI Definition
SE18 (BAdI Definition) Screen has additional option (Enhancement Spot)
BAdI definition
Enter name for the Interface and click on ‘Change’
Create Method & it’s parameters
BAdI definition
Click on this to create an Enhancement Implementation
Specify a ‘Fallback Class’ to be executed if no active Implementation is found
BAdI Implementation
Expand the Node for ‘Implementing Class’
Specify the ‘Implementing Class’ and click on Change
Report program to call BADI:
DATA: handle type ref to <BAdI_Name>
<other data declarations…>
GET BADI handle
CALL BADI handle 🡪 <method_name>
EXPORTING …
IMPORTING …
Filter-dependent BAdI
What is a Filter-Dependent BAdI?
Filter-dependent BAdI
Create a new Implementation for the same BADI definition we created earlier.
Filter-dependent BAdI Implementation
Filter-dependent BAdI Implementation
Filter-dependent BAdI Implementation
Filter-dependent BAdI Implementation
Multiple-use BAdI
What are Multiple-use BAdI?
Example: BAdI that converts data for different output devices. Hence, call of a method of a multiple-use BAdI is akin to sending a message. It does not matter how many services react to the message. It is similar to Publish & Subscribe mechanism.
Context Objects (new concept in Enhancement Framework)
How are they defined & used?
DATA <context> TYPE REF TO <cl_myctx>
GET BADI <handle> CONTEXT <context>
Whenever ‘GET BADI’ is called with the same context & a filter value which leads to the same implementation class, the already created instance is used.
Advantages of using Contexts:
What do you mean by Contexts?
Switch Implementations (new Switch Framework)�
Enhancement Framework
Editor Modes for Enhancements
Source Code plug-in
Transaction Code: SE18
Enter name of the enhancement spot and click on display button
Source Code plug-in
On double clicking on any of the enhancement-point, system will display the code behind each of them
Source Code plug-in
To insert new implementation for enhancement point, click on the spiral button.
Source Code plug-in
In order to create an implementation for an enhancement point, right click on enhancement point and then select create option from context menu.
Source Code plug-in
Click on create button to create enhancement implementation
Source Code plug-in
Enter the name of the enhancement implementation and short text, and then choose this option
Source Code plug-in
Select the newly created enhancement implementation and then select this option
Source Code plug-in
You can include your source code here.
Function Module Enhancement
Specify Implementation name and its short text
Inorder to enhance the functional module with new parameter, choose this option
Function Module Enhancement
Before Activation
After Activation
Class/Interface Enhancement
Class/Interface Enhancement
Class/Interface Enhancement
Class/Interface Enhancement: Pre/Post Exits
Enhancements, Exits and BADI's
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
Exercises
Table enhancement - Append structure (2 Char fields ) for Table SFLIGHT**
To trigger all the customer exit (Function , Menu and Screen Exit) for Program SAPBC425_FLIGHT**
Create a project using following Components
SBC**E01(Function Exit)
(** => ranges from 00 to 18)
Name of the Functionality
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
HelpMe
HelpMe
Tips and Tricks
SAP application programmers use the ABAP statement CALL CUSTOMER-FUNCTION 'nnn' to call function modules (where 'nnn' is a three-digit number). They must also create the function module they want z CALL CUSTOMER-FUNCTION )
These function modules are always belong to function groups whose names begin with X (X function groups).��
The following naming convention applies to these function modules:
prefix: EXIT
name of the program that calls the function module
suffix: three-digit number��
The three parts of the name are separated by two underscores.��
The CALL CUSTOMER-FUNCTION statement is not executed until the corresponding enhancement project is activated. Multiple calls of the same function module are all activated at the same time.
HelpMe
Additional Info
Searching BADI: Method 1
Search for BAdI corresponding to the transaction:
Method 1: Search for the CL_EXITHANDLER=>GET_INSTANCE in the main program
Searching BADI: Method 2
Put a breakpoint at the following code and execute the transaction (e.g. MM01)
We want to implement a BAdI on Saving Material Data.