You are on page 1of 55

Business Consulting Services

Business Add-Ins

November, 2003

deeper

Copyright IBM Corporation 2003

Business Consulting Services

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

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Introduction
Traditional way of doing code modifications Exits 3 Tier Architecture
PRESENTATION :
Field 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 Application Layer.

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdIs
Business Add-Ins are a new SAP enhancement technique based on ABAP Objects They can be inserted into the SAP system based on specific user requirements Business Add-Ins should be considered generalized Business Transaction Events that can be used to bundle program, menu and screen enhancements into a single add-in. Each Business Add-In has :
at least one Business Add-In definition

a Business Add-In interface


a Business Add-In class that implements the interface

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Enhancement options


In Business Add-Ins, all the components of an enhancement option are grouped together
Program Enhancements: Functional enhancement of the program are defined in the form of interface methods and can be used with or without Menu Enhancements or Screen Enhancements Menu Enhancements: Function codes can be entered for a BAdI for the corresponding menu entries in the user interface definition. Screen Enhancements: Subscreen areas can be entered for a Business Add-In. Screen enhancements can be implemented for these in the form of subscreen screens.

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdIs SAP Delivered vs. Custom Developed


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) of these existing BAdIs, entering custom code into the implemented methods It is also possible for developers to create new BAdI definitions, and reference them in their own custom code. You would do this if you wanted to give future users of your application the ability to expand on functionality in a custom development. You would NOT define 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 does something.

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs
SE18

Enter BADI name

Click on CREATE

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs Attributes

Enter short text

BADI class is automatically created

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BADI Definition - Save

Enter Package name

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs

Package name populated

BAdI class created

10

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs - Interface

BADI Interface is created automatically To edit double click on the interface

11

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs Interface methods

Method name Method type

12

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs Interface methods - parameters

Import and Export parameters

13

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Defining BAdIs Exceptions

Exceptions

14

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BADI Implementation
SE19

Enter Implementation name

Click on create

Enter the BAdI Definition name

15

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Implementation

Double click on the method to modify method code

16

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Implementing BAdIs: Method implementation

Modify the method code within the METHOD/ENDMETHOD statements and activate

17

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Using a BAdI

18

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Create an Implementation for an SAP provided BAdI


Find the corresponding BAdI for the SAP transaction Create a custom Implementation for the BAdI From the methods available in the BAdI and select the appropriate method Enter custom code in the method and activate

Execute SAP transaction and test if method with custom code is being invoked

19

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Transaction VD02

Select System->Status from the drop down menu

20

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Transaction VD02

Double click on the program name

21

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Source program

Do a search on CL_EXITHANDLER=> GET_INSTANCE

22

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Search results

Three BAdIs used in this program. Double click required BAdI to see the source code

23

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Call to a BAdI in the source code

BAdI being used

Interface reference Variable for the BAdI

24

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Finding a BAdI Interface reference to the BAdI

Interface reference Variable defined

25

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Using an SAP BAdI Create a Custom Implementation


SE19
Enter the implementation name

Click on CREATE

Enter the name of the BAdI

26

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Implementation Attributes

Enter description

27

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Implementation Interface methods

Click on the interface tab to view the available methods

Double click on method SAVE_DATA to modify it

28

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Implementation Class builder

Enter custom code

29

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdIs Execute the Change customer transaction


VD02
Click on SAVE button

Change name of Customer

30

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

BAdI Implementation Invoked by VD02

Custom code for method invoked via BAdI CUSTOMER_ADD_DATA

31

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Multiple Use BAdIs


Single Use Business Add-Ins
Do NOT select the Multiple use checkbox from the Administration tab when defining a Single Use BAdI BAdI has a single Implementation Similar to procedures

Multiple Use Business Add-Ins


Select the Multiple use checkbox from the Administration tab when creating the BAdI definition BAdI has multiple implementations Similar to event calls

Return values can be expected


Can use importing, changing and returning parameters N/A

Cannot expect return values


Can use importing and changing parameters For multiple implementations there is no sequence control because at the time of BAdI definition it does not know which implementation will be active All active implementations will be triggered by the application program using the BAdI
Copyright IBM Corporation 2003

A single implementation will be triggered by the application program

32

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Business Consulting Services

Multi Use BAdIs CUSTOMER_ADD_DATA Definition

SAP defined BAdI CUSTOMER_ADD_DATA

Multiple use Button checked

33

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Multi Use BAdIs Custom Implementation for BAdI CUSTOMER_ADD_DATA

Create a second implementation for BAdI CUSTOMER_ADD_DATA Click on CREATE

Specify BAdI name

34

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Multi Use BAdIs Interface method SAVE_DATA

Double click on method SAVE_DATA

35

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Multi Use BAdIs Modify method SAVE_DATA

Enter custom code for method SAVE_DATA

36

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Multi Use BAdIs View implementations for BAdI


SE18
Select to display list of Implementations for BAdI CUSTOMER_ADD_DATA

Displays list of Implementations

37

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs


Business Add-Ins can be implemented based on a specific filter value If you want to call the implementation of a Business Add-In depending not 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

38

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs BAdI Definition


SE18

Click checkbox for Filter Dependent BAdIs

Enter Filter type

39

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs BAdI Definition

Enter text Double click on the Interface to add parameters and methods

40

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs Interface - Method Definition

41

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs Interface Parameter Definition

Create parameter to export tax rate

FLT_VAL parameter preset for method

42

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs Implementation

Create BAdI Implementation

Select CREATE button

Enter name of BAdI

43

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs BAdI Implementation


SE19

Click on button to create an entry for filter value Select a value from the search help or enter a valid value

44

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs BAdI Implementation

Select the Interface tab

Double click on the Method to enter source code

45

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs Method code

Save and activate

Enter code for the Method to calculate the tax rate based on the company code in Parameter FLT_VAL

46

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Filter Dependent BAdIs Source code to Invoke BAdI

Selection screen parameter for Company code

Call BADI from within the program

Call method get_bukrs passing the company code The Tax rate is returned

47

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Creating a menu enhancement

SE18 Create BADI definition

Fcodes tab is only available when multiple use box is not checked

Menu enhancements are for Single Use BAdIs only

48

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Definition via SE18 FCode Tab

Enter related program and function code information. Double clicking on the new line will take you to dialog for defining an icon and function texts

49

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Function Code Attributes

Function texts screen shows all codes for associated program

Function attributes popup allows definition of code type and static texts

50

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Define the Interface (SE18)

Add method to interface that will be implemented by the menu exit

51

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Implement BAdI in SE19

Double click on method to add in custom code for the implementation

Dont forget to activate during all steps in this process!


52 ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014
Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Enter Fcode in GUI status

Dont forget to activate during all steps in this process!


53 ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014
Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Call the 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

54

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

Business Consulting Services

Menu Enhancement BAdIs Call the BADI in Application!

55

ABAP | Confidential | 15_BAdl v1 .ppt | 3/12/2014

Copyright IBM Corporation 2003

You might also like