Document On BADI
Document On BADI
Document On BADI
1 Lesson Objectives
2 Introduction
2.1 PRESENTATION
2.2 APPLICATION
2.3 DATABASE
3 BAdIs
5 Defining BAdIs
7 Defining BAdIs
8 BADI Implementation
9 BAdI Implementation
10 Using a BAdI
14 BAdIs
15 Three BAdIs used in this program
[edit]
Lesson Objectives
[edit]
Define BAdIs
Implement BAdIs
Use BAdIs
[edit]
Introduction
[edit]
PRESENTATION
Field Exits
Screen Exits
Menu Exits
[edit]
APPLICATION
Programs -> Program exits -> call customer function -> Include
[edit]
DATABASE
With BAdIs you can make changes only at the Application Layer.
The traditional way of doing code modifications was via User exits.
As per SAPs 3 Tier Architecture, at the Presentation layer you had Field Exits,
Screen Exits and Menu Exits. At the Application layer you had Program exits,
at the Database layer you could Append structures to the existing SAP
structures.
[edit]
Document on BADI
BAdIs
Objects]]
They can be inserted into the SAP system based on specific user
requirements
An adapter class with CL_EX_ inserted between the first and second
characters
can be used
[edit]
grouped together
Menu Enhancements: Function codes can be entered for a BAdI for the
[edit]
Defining BAdIs
Click on CREATE
SE18
To define a BAdI use Sap Menu -> Tools -> ABAP Workbench -> Utilities ->
Business
[edit]
When a BAdI is created, BADI class gets automatically created with the suffix
CL_EX_ after the first character of the BAdI name.
[edit]
[edit]
Defining BAdIs
[edit]
An interface is created automatically with the suffix IF_EX_ after the first
character of the BAdI name
into the class builder where you can define the methods, parameters and
exceptions for that interface
[edit]
Defining BAdIs Interface methods
Method name
Method type
Instance methods can access all of the attributes of a class, and can trigger
all of the events of the class
Static methods can only access static attributes and trigger static events
[edit]
The type, default value and description of the parameter can be specified
[edit]
Exceptions
[edit]
BADI Implementation
SE19
Definition name
Enter the name of the BAdI you want to create an implementation for
in the dialog box that appears.
[edit]
BAdI Implementation
[edit]
Insert the source code between the method and endmethod statements and
activated.
[edit]
Using a BAdI
In order to be able to call static methods, you must declare the corresponding
class in ABAP Objects using the class definition load statement
In the example having created a BAdI for division, you can program the call
for the BAdI in the following manner:
L_BADI_INSTANCE.
[edit]
From the methods available in the BAdI and select the appropriate method
Execute SAP transaction and test if method with custom code is being
invoked
[edit]
Click on System->Status
[edit]
[edit]
BAdIs
[edit]
Interface reference
Interface reference
Variable defined
SE19
Click on CREATE
Go to transaction SE19
Enter the name of the standard SAP BADI that you want to implement
[edit]
Enter description
[edit]
SAVE_DATA to modify it
In the interfaces tab you will find a list of methods included in the BAdI
Interface
Double clicking on any of the methods will take you into the Class Builder
where you can enter custom code for the corresponding method
[edit]
In our example we have chosen the SAVE_DATA method to enter our code
changes
Double clicking on the SAVE_DATA method takes us into the class builder
You can enter your code changes between the method, endmethod
statements
Enter the custom code that will be executed when customer data is saved in
transaction VD02.
[edit]
VD02
Go into the change customer transaction VD02 and change the name of the
customer
custom implementation.
[edit]
CUSTOMER_ADD_DATA
When you hit the SAVE button, the code entered in the SAVE_DATA method is
executed.
[edit]
Do NOT select the Multiple use checkbox from the Administration tab
when defining a Single Use BAdI
Similar to procedures
N/A
Select the Multiple use checkbox from the Administration tab when
creating the BAdI definition
[edit]
Multiple use
Button checked
SAP defined BAdI CUSTOMER_ADD_DATA
Click on CREATE
SAVE_DATA
Double click on method SAVE_DATA TO enter the class builder where you can
enter custom code for this method.
[edit]
Enter the custom code for the method SAVE_DATA in the class builder and
activate.
SE18
Displays list of
Implementations
CUSTOMER_ADD_DATA
To view all implementation for BAdi CUSTOMER_ADD_DATA go to the BAdI
definition in se18. Click on Implementation->Display.
You can CREATE, CHANGE, DISPLAY and DELETE Implementations from here.
Both BAdIs will be triggered when the customer data is modified in transaction
VD02 and saved.
only on one filter value but on various values, you can enter the name of a structure
into the Filter type field. The structure can consist of several data elements that
fulfill the above conditions for data elements Filter Dependent BAdIs BAdI
Definition
SE18
A filter type can be a data element or a structure. A data element must fulfill
the following criteria:
of type Character.
The data element must 1). either have a search help with a search help
parameter of the same type as the data element and this parameter
must serve as both the import and export parameter or 2). the
element's domain must have fixed domain values or a value table
containing a column with the same type as the data element.
[edit]
Enter text
When you double click on the interface it takes you to the class builder where
you can add methods, parameters, and exceptions to the interface.
Now create an interface with a method. Be aware that for each method you
create in the interface of a filter-dependent enhancement, the appropriate
filter value must be defined as the import parameter so that the application
program can provide the filter value to the enhancement method. The
method then selects the active implementation for that value.
[edit]
The filter value is declared using parameter flt_val and is preset in the list of
parameters.
SE19
Create a BAdI
[edit]
Method to calculate the tax rate based on the company code in Parameter
FLT_VAL
The parameter FLT_VAL will have the company code value passes to the
implementation.