LESSON OVERVIEW
In this lesson, you will learn how program and menu exits, which are implemented using Business Add-Ins (BAdIs), work. You will also find out how to find and use BAdIs.
Business Example
You have to enhance your SAP software by using classic BAdIs delivered in the standard SAP system. For this reason, you require the following knowledge:
● How to search for available BAdIs in SAP programs
● How to use BAdIs to implement program enhancements LESSON OBJECTIVES
After completing this lesson, you will be able to:
● Enhance programs using classic BAdIs
Business Add-In Implementation
Figure 94: Implementing BAdIs – Introduction
To implement BAdIs, use transaction SE19 and follow the steps below:
1. Go to Tools → ABAP Workbench → Utilities → Business Add-Ins → Implementation.
2. Enter a name for the implementation and choose the Create pushbutton.
3. A dialog box appears. Enter the name of the BAdI. The maintenance screen for the BAdI then appears.
© Copyright . All rights reserved. 127
Alternatively, you can use the BAdI definition transaction SE18 to reach its implementations.
You can choose Implementation on the menu to get an overview of the existing implementations. You can also create new implementations from here.
Note:
As of SAP NetWeaver Application Server 7.0, there are new BAdIs in addition to the older and classical ones. (The initial screen of transaction SE19 has been adjusted appropriately. To create an implementation for a classical BAdI, select Classical BAdI in the lower input area of the initial screen. Enter the BAdI name in the corresponding field. Choose Create Implementation.
Implementing BAdIs – Methods
Figure 95: Implementing BAdIs – Methods
You can assign any name to the implementing class. However, you should observe the proposed naming convention.
You can construct the suggested name as follows:
● Namespace prefix, Y, or Z
● CL_ (for class)
● IM_ (for implementation)
● Name of the implementation (without namespace prefix)
To implement the method, double-click its name. The system starts the Class Builder editor.
After finishing, you must activate the objects.
Unit 6: Classic Business Add-Ins
Implementing BAdIs – Private Methods
Figure 96: Implementing BAdIs – Private Methods
In the implementing class, you can create private methods that you call from the interface method. To do this, you must edit the implementing classes directly in the Class Builder. You can create the private methods including interfaces. Specify a visibility level for the method and implement the same.
Implementing BAdIs – Activating Implementations
Figure 97: Implementing BAdIs – Activating Implementations
Use the <Activate> icon to activate the implementation of a BAdI. The methods of the implementation are now executed when the relevant calling program is executed.
If you deactivate the implementation, the system no longer calls the methods. However, the corresponding calls in the application program are still processed. The difference is that the instance of the adapter class no longer finds any active implementations. Unlike CALL
Lesson: Enhancing Programs Using Classic BAdIs
© Copyright . All rights reserved. 129
CUSTOMER-FUNCTION, the CALL_METHOD CL_EXITHANDLER=> GET_INSTANCE call is executed even when there are no implementations. The same applies to the method call that calls the method of the adapter class.
You can only activate or deactivate an implementation in its original system without modification. However, this must be transported into the subsequent systems.
If a BAdI can have only one implementation, there can still be more than one in the same system. However, only one can be active at one time.
BAdIs – Menu Exits (Overview)
Figure 98: BAdIs – Menu Exits (Overview)
To use menu enhancements with BAdIs, you must ensure the following conditions are met:
● The developer of the program you want to enhance must have planned for the enhancement.
● The menu enhancement must be implemented in a BAdI implementation.
Unit 6: Classic Business Add-Ins
BAdIs – Menu Exits (SAP Preparation)
Figure 99: BAdIs – Menu Exits (SAP Preparation)
Function codes of menu enhancements begin with a plus sign, +. The menu option appears only if there is an active BAdI implementation containing the corresponding enhancement.
BAdIs – Menu Exits (Function Code Processing)
Figure 100: BAdIs – Menu Exits (Function Code Processing)
If the user chooses the menu option in the program to which the function code, +<exit> is assigned, the system processes the relevant method call.
The method call and the menu enhancement are always performed together. For this reason, it’s important that the two enhancement components are combined in a single enhancement, the BAdI.
Lesson: Enhancing Programs Using Classic BAdIs
© Copyright . All rights reserved. 131
BAdIs – Menu Exits (Restrictions)
Figure 101: BAdIs – Menu Exits (Restrictions)
You can create only function codes for single use BAdIs. The BAdIs must not be filter-dependent.
These restrictions are necessary to ensure that there are no conflicts between two or more implementations. (“Which menu option should be displayed?”)
Demonstration: How to Implement Business Add-Ins To implement BAdIs, perform the following steps:
1. Start program SAPBC425_BOOKING_00.
2. Point the additional data shown in the list. From the list, choose Menu System → Status.
3. Double-click the program name and search for the string CL_EXITHANDLER.
4. From the result list, find which BAdI definition is used for implementation in TA SE19.
5. To do this, double-click the result. In the ABAP editor, select the reference variable exit_book, which takes the BAdI Object from the CL_EXITHANDLER -> get_instance method.
6. Ignore IF_EX_ from the interface name and you will get the name of the BAdI.
7. Go to TA SE18 to read the documentation for this BAdI. Choose Menu Implementation → Create to implement the BAdI.
8. Implement the interface methods in the proposed customer class. Activate this and the implementation as well.
9. Start the program again and you will see the result.
Unit 6: Classic Business Add-Ins