View
244
Download
3
Category
Preview:
Citation preview
7/30/2019 BADI Material Final
1/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
BADIs
U V S Varma
7/30/2019 BADI Material Final
2/54
Co ri ht 20092
Lesson Objectives
After completing this lesson you will be able to :
Understand what Business Add Ins (BAdIs) are
Define BAdIs
Implement BAdIs
Use BAdIs
Create an implementation for an existing SAP BAdI
Create Multiple Use BAdIs
Create Filter Dependent BAdI
Create Menu Enhancement with BAdI
7/30/2019 BADI Material Final
3/54
Co ri ht 20093
Introduction
Traditional way of doing code modifications Exits
3 Tier Architecture
PRESENTATION :
Function Exits
Screen Exits
Menu Exits
APPLICATION:
Programs -> Program exits -> call customer function -> Include
DATABASE
Table -> SE11 -> Goto -> Append Structure
With BAdIs you can make changes only at the ApplicationLayer.
7/30/2019 BADI Material Final
4/54
Co ri ht 20094
BAdIs
Business Add-Ins are a new SAP enhancement technique based onABAP Objects
They can be inserted into the SAP system based on specific userrequirements
Business Add-Ins should be considered generalized Business
Transaction Events that can be used to bundle program, menu andscreen enhancements into a single add-in.
Each Business Add-In has :
at least one Business Add-In definition
a Business Add-In interfacea Business Add-In class that implements the
interface
7/30/2019 BADI Material Final
5/54
Co ri ht 20095
BAdI Enhancement options
In Business Add-Ins, all the components of an enhancementoption are grouped together
Program Enhancements: Functional enhancement of theprogram are defined in the form of interface methods and
can be used with or without Menu Enhancements orScreen Enhancements
Menu Enhancements: Function codes can be entered for aBAdI for the corresponding menu entries in the userinterface definition.
Screen Enhancements: Subscreen areas can be enteredfor a Business Add-In. Screen enhancements can beimplemented for these in the form of subscreen screens.
7/30/2019 BADI Material Final
6/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
6
BAdIs SAP Delivered vs. CustomDeveloped SAP has already created BAdI definitions (created with SE18)
and placed references to these throughout the application code.
SAP developers create implementations(created with SE19) ofthese existing BAdIs, entering custom code into the implementedmethods
It is also possible for developers to create new BAdI definitions,and reference them in their own custom code. You would do thisif you wanted to give future users of your application the ability toexpand on functionality in a custom development. You would NOTdefine a new BAdI to place in SAP code!
Overview of steps to complete a BAdI.
1. Create BAdI definition with SE18 2. Code a reference to the BAdI in application code where
functionality is to be expanded
3. Create an implementation of the BAdI that actually doessomething.
7/30/2019 BADI Material Final
7/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
7
Defining BAdIs
Enter BADI name
Click on CREATE
SE18
7/30/2019 BADI Material Final
8/54Co ri ht 20098
Defining BAdIs Attributes
Enter short text
BADI class is automatically created
7/30/2019 BADI Material Final
9/54Co ri ht 20099
BADI Definition - Save
Enter Package name
7/30/2019 BADI Material Final
10/54Co ri ht 200910
Defining BAdIs
Package name populated
BAdI class created
7/30/2019 BADI Material Final
11/54Co ri ht 200911
Defining BAdIs - Interface
BADI Interface is
created automaticallyTo edit double click
on the interface
7/30/2019 BADI Material Final
12/54Co ri ht 200912
Defining BAdIs Interfacemethods
Method name
Method type
7/30/2019 BADI Material Final
13/54Co ri ht 200913
Defining BAdIs Interfacemethods - parameters
Import and
Export parameters
7/30/2019 BADI Material Final
14/54Co ri ht 200914
Defining BAdIs Exceptions
Exceptions
7/30/2019 BADI Material Final
15/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
15
BADI Implementation
SE19
Enter Implementation name
Click on create
Enter the BAdIDefinition name
7/30/2019 BADI Material Final
16/54Co ri ht 200916
BAdI Implementation
Double click on
the method to modify
method code
7/30/2019 BADI Material Final
17/54Co ri ht 200917
Implementing BAdIs: Methodimplementation
Modify the methodcode within the
METHOD/ENDMETHOD
statements and activate
7/30/2019 BADI Material Final
18/54Co ri ht 200918
Using a BAdI
7/30/2019 BADI Material Final
19/54Co ri ht 200919
Create an Implementation for anSAP provided BAdI
Find the corresponding BAdI for the SAPtransaction
Create a custom Implementation for the BAdI
From the methods available in the BAdI and selectthe appropriate method
Enter custom code in the method and activate
Execute SAP transaction and test if method with
custom code is being invoked
7/30/2019 BADI Material Final
20/54Co ri ht 200920
Finding a BAdI Transaction VD02
Select System->S
from the drop dow
7/30/2019 BADI Material Final
21/54Co ri ht 200921
Finding a BAdI Transaction VD02
Double click on the
program name
7/30/2019 BADI Material Final
22/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
22
Finding a BAdI Source program
Do a search on
CL_EXITHAND
GET_INSTANC
7/30/2019 BADI Material Final
23/54Co ri ht 200923
Finding a BAdI Search results
Three BAdIs usein this program.
Double click requ
BAdI to see the
source code
7/30/2019 BADI Material Final
24/54Co ri ht 200924
Finding a BAdI Call to a BAdI inthe source code
BAdI being used
Interface referencVariable for the BA
7/30/2019 BADI Material Final
25/54Co ri ht 200925
Finding a BAdI Interfacereference to the BAdI
Interface refere
Variable defined
7/30/2019 BADI Material Final
26/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
26
Using an SAP BAdI Create aCustom Implementation
Enter the name
of the BAdI
SE19
Enter the
implementation
name
Click on CREAT
7/30/2019 BADI Material Final
27/54Co ri ht 200927
BAdI Implementation Attributes
Enter description
7/30/2019 BADI Material Final
28/54
Co ri ht 200928
BAdI Implementation Interfacemethods
Click on the inter
tab to view the a
methods
Double click on m
SAVE_DATA to m
7/30/2019 BADI Material Final
29/54
Co ri ht 200929
BAdI Implementation Classbuilder
Enter custom code
7/30/2019 BADI Material Final
30/54
Co ri ht 200930
BAdIs Execute the Changecustomer transaction
Change name of Cust
Click on SAVE button
VD02
7/30/2019 BADI Material Final
31/54
Co ri ht 200931
BAdI Implementation Invokedby VD02
Custom code for method
invoked via BAdI
CUSTOMER_ADD_DATA
7/30/2019 BADI Material Final
32/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
32
Multiple Use BAdIs
Single Use Business Add-Ins
Do NOT select the Multiple usecheckbox from the Administrationtab when defining a Single Use BAdI
BAdI has a single Implementation
Similar to procedures
Return values can be expected Can use importing, changing and
returning parameters
N/A
A single implementation will betriggered by the applicationprogram
Multiple Use Business Add-Ins
Select the Multiple use checkboxfrom the Administration tab whencreating the BAdI definition
BAdI has multiple implementations
Similar to event calls
Cannot expect return values Can use importing and changing
parameters
For multiple implementations thereis no sequence control because atthe time of BAdI definition it doesnot know which implementation will
be active All active implementations will be
triggered by the applicationprogram using the BAdI
7/30/2019 BADI Material Final
33/54
Co ri ht 200933
Multi Use BAdIs CUSTOMER_ADD_DATA Definition
Multiple use
Button checked
SAP defined BAdI
CUSTOMER_ADD_DATA
7/30/2019 BADI Material Final
34/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
34
Multi Use BAdIs CustomImplementation for BAdI
CUSTOMER_ADD_DATA
Create a second implement
for BAdI CUSTOMER_ADD
Specify BAdI name
Click on CREATE
7/30/2019 BADI Material Final
35/54
Co ri ht 200935
Multi Use BAdIs Interfacemethod SAVE_DATA
Double click on metho
SAVE_DATA
7/30/2019 BADI Material Final
36/54
Co ri ht 200936
Multi Use BAdIs Modify methodSAVE_DATA
Enter custom code formethod SAVE_DATA
7/30/2019 BADI Material Final
37/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
37
Multi Use BAdIs Viewimplementations for BAdI
SE18
Displays list of
Implementation
Select to display li
Implementations f
CUSTOMER_AD
7/30/2019 BADI Material Final
38/54
Co ri ht 200938
Filter Dependent BAdIs
Business Add-Ins can be implementedbased on a specific filter value
If you want to call the implementation of a
Business Add-In depending not only onone filter value but on various values, youcan enter the name of a structure into theFilter type field. The structure can consist
of several data elements that fulfill theabove conditions for data elements
7/30/2019 BADI Material Final
39/54
Co ri ht 200939
Filter Dependent BAdIs BAdIDefinition
SE18
Click checkbox for
Filter Dependent BAdIs
Enter Filter type
7/30/2019 BADI Material Final
40/54
Co ri ht 200940
Filter Dependent BAdIs BAdIDefinition
Double click on
the Interface toadd parameters
and methods
Enter text
7/30/2019 BADI Material Final
41/54
Co ri ht 200941
Filter Dependent BAdIs Interface- Method Definition
7/30/2019 BADI Material Final
42/54
Co ri ht 200942
Filter Dependent BAdIs Interface Parameter Definition
_VAL parameter
reset for method
eate parameter to
export tax rate
7/30/2019 BADI Material Final
43/54
Copyright 2006 Deloitte Development LLC. All rights reserved.
43
Filter Dependent BAdIs Implementation
Create BAdI Impleme
Enter name of BAdI
Select CREATE butto
7/30/2019 BADI Material Final
44/54
Co ri ht 200944
Filter Dependent BAdIs BAdIImplementation
SE19
Select a value from
the search help or
enter a valid value
Click on button to
create an entryfor filter value
7/30/2019 BADI Material Final
45/54
Co ri ht 200945
Filter Dependent BAdIs BAdIImplementation
Double click on
the Method to
enter source code
Select the
Interface tab
7/30/2019 BADI Material Final
46/54
Co ri ht 200946
Filter Dependent BAdIs Methodcode
Enter code for the
Method to calculatethe tax rate based on
the company code in
Parameter FLT_VAL
Save and activate
7/30/2019 BADI Material Final
47/54
Co ri ht 200947
Filter Dependent BAdIs Sourcecode to Invoke BAdI
Call BADI from
within the program
Selection screen
parameter forCompany code
Call methodget_bukrs passing
the company code
The Tax rate is
returned
7/30/2019 BADI Material Final
48/54
Co ri ht 200948
Menu Enhancement BAdIs Creating a menu enhancement
Fcodes tab is only
available when
multiple use box is
not checked
SE18 Create
BADI definition
Menuenhancements
are for Single
Use BAdIs
only
7/30/2019 BADI Material Final
49/54
Co ri ht 200949
Menu Enhancement BAdIs Definition via SE18 FCode Tab
Enter related
program andfunction code
information.
Double clicking on
the new line will
take you to dialog
for defining an iconand function texts
7/30/2019 BADI Material Final
50/54
Co ri ht 200950
Menu Enhancement BAdIs Function Code Attributes
Function texts
screen shows allcodes for
associated
programFunction attributes
popup allows
definition of code
type and static
texts
7/30/2019 BADI Material Final
51/54
Co ri ht 200951
Menu Enhancement BAdIs Define the Interface (SE18)
Add method
to interfacethat will be
implemented
by the menu
exit
h d
7/30/2019 BADI Material Final
52/54
Co ri ht 200952
Menu Enhancement BAdIs Implement BAdI in SE19
Double click
on method toadd in
custom code
for the
implementati
on
Dont forget to activate during all steps in this
process!
h d
7/30/2019 BADI Material Final
53/54
Co ri ht 200953
Menu Enhancement BAdIs EnterFcode in GUI status
Dont forget to activate during all steps in this
process!
M E h BAdI C ll
7/30/2019 BADI Material Final
54/54
Menu Enhancement BAdIs Callthe BADI in Application
Dont forget to create a reference to the BADI instance in GLOBAL memory of the
application as follows:
DATA o_exit TYPE REF TO zif_ex__menu_exit_badi_1. "BADI interface
Recommended