Вы находитесь на странице: 1из 10

Information about Badi

Understanding Business Add-ins (BADI)


By Vikram Chellappa

Basic concept SAP has introduced new enhancement technique Business Add-ins from release 4.6A. Business Add-in is the new enhancement technique based on ABAP Objects. BADI is an exit point in a source that allows specific industry sectors, partners, and customers to attach additional software to standard SAP source code with out modifying the original object. The users of Business Add-ins can customize the logic according to requirement or they can use the standard logic one available. SAP guarantees the upward compatibility of all Business Add-in interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. Basic skills required Work Experience/Knowledge on ABAP Objects (Object orientation of ABAP) is mandatory. Experience on SAP enhancement technique.

BADI in detail Business Add-ins infrastructure is multi-level system landscape (SAP, partner, customer solutions, as well as country versions, and industry solutions). Definitions and implementations of Business Add-ins at each level within system infrastructure. Different Views The different views of the BADIs are:

1. Definition view, Application Programmer can predefine the exit points in the source in which specific industry sector customers can attach additional software to standard SAP source code with out having to modify the original object. 2. Implementation view, the users of Business Add-ins can customize the logic they need or use a standard logic if available.
Architecture

User defined BADIs:

i.
ii. iii.

First define a Business Add-In, application developer creates an interface for the add-in. Enhancement management creates an adapter class that implements the interface and thus provides the interface for implementation by the customer, partner and so on. The programmer/developer creates an instance of the adapter class in the application program and calls the corresponding method at the appropriate time.

Standard BADIs: i. For Standard Business Add-ins, the interface and adapter class will be predefined by SAP. The adapter class that implements the interface and provides the interface for implementation by the customer, partner specific to business.

Each Business Add-in will have one interface and an adapter class that implements interface. Depending on the business requirement user will implement the interface. The generated class (Adapter class) has the following tasks:

1. Control, the adapter class calls the active implementations 2. Filtering, If the Add-in has to be executed under certain conditions, then the adapter class
ensures that only certain implementations will be executed. Technical Details a. BAdIs are contained in the system and are fully operational as of Release 4.6B. SAP creates Add-ins for specific programs, menus, and screen enhancements for standard R/3 applications. This Add-ins doesnt contain any functionality. Instead you can add-on functionality onto these hooks.

b.

Customers can find the enhancements in their system in the implementation guide and in the component hierarchy. If customer wishes to use a Business Add-in, he has to first create an implementation. The customer must implement the methods and the enhancements, and

afterwards activate the implementation of the enhancement. The enhancements active components are then called at runtime.

c.

Business Add-in contains an interface and other additional components such as function codes for menu enhancements. Business Add-ins also includes enhancements for screens. The enhancement, interface and generated classes are all located in the appropriate application development namespace. Business Add-in implementations are created in the respective implementation namespace.

Defining and Implementing Business Add-ins (BADI) (Step-bystep with screenshots)


By Vikram Chellappa

Defining a Business Add-in SAP provides the BADIs where are applicable in the standard applications. Application programmer whoever wishes to have a Business Add-ins in a particular program can define the interface for an enhancement in the Business Add-in builder. Programmer has to program the interface call in the program at the appropriate place. Customers can select the add-in and implement it accordingly to their business needs. 1. From SAP menu, choose Tools -> ABAP Workbench -> Utilities -> Business Add-ins or transaction code SE18. The example, which is illustrated, is the string conversion in the program. And giving the provision to the users to determine themselves how their strings are to be converted. Application developer define an enhancement, consists of interface with a method with changing parameter used to pass the string. 2. Enter the BADI name and choose create

3. Enter the short text, choose the interface tab.

4. Double click on the interface name field. The system branches to the class builder.

5. In the class builder assign a method to the interface and define a parameter with the attributes.

6. Save and activate the interface and navigate back to the Business Add-in definition. Now in the BADI screen, displays the method you have created for the interface. When you maintain the interface methods, corresponding executing class (Adapter class) is generated. 7. Save your entries and document the description of the Business Add-in. Documentation is important for the users to understand the purpose of the Add-in. Implementation of BADI 1. The list of Business Add-ins available in the system can be found through SAP Reference Implementation guide (IMG) or in component hierarchy. BADIs definition is included in IMG so that the customer/partner can create suitable, company-specific implementations

2. In the SAP menu, choose ABAP Workbench -> Utilities -> Business Addins or transaction code SE19.
3. Enter the implementation name and click on the create button.

4. Enter the BADI name

5. Enter the short description for the BADI implementation and implement the interface in the class appearing in the BADI implementation screen.

6. Double click on the implementation class and insert the desired source code for the
implementation between the method ZIF_EX_BUSINESSADDIN~CONVERSION. And Method. In this particular example enter the statement translate parameter to upper case. Save and activate your entries and return to the change implemention screen.

7. Choose Activate, now you can use this implementation when the application program is
executed. Several implementations may exist for a Business Add-in but that is not used in multiple use basis. However only one implementation can be activate at any one time. But in case of multiple use of the BADI, we can have multiple implementations activate. The instance generation of the implementing class must set the attribute as public and not as private, protected or abstract. System will give dump if you do so. 8. Following is the code for the class ZCL_CONVERSION_BADI_IMPL method CONVERSION Method ZIF_EX_BUSINESSADDIN~CONVERSION. translate parameter to upper case. endmethod. Calling BADI in the Application

1. When we define BADI, enhancement management generates a class that implements the
interface. The application developer uses a factory method to create an instance of adapter class in the application program and calls corresponding method. The adapter class method generated by the enhancement management decides by checking the entries in the table whether one or several active implementations need to be called. If required, the implementations are subsequently executed. The application program ensures only the adapter class method is called. The application program doesnt know which implementations are called. 2. Call the string conversion Business Add-in, the program calling the Business Add-in. Following is the ABAP source code REPORT ZMPTEST_BADI. * Declaring the handler class: cl_exithandler definition load. * Interface Reference data: badi_interface type ref to ZIF_EX_BUSINESSADDIN. * String data: w_str(15) type c value 'baddi test'. ************************************************* ****Start of Selection Event..................... ************************************************ start-of-selection. call method cl_exithandler=>get_instance changing instance = badi_interface. write: / 'Please click here'. ************************************************* ****At line-selection Event..................... ************************************************ at line-selection. write: / 'original word', w_str. if not badi_interface is initial. call method badi_interface->conversion changing parameter = w_str. endif. write: / 'Converted word', w_str. Filter dependent Badi

1.

2. 3.

Business Add-in definition level (for example a country, industry sector) we can have filter dependent option. If an enhancement for country specific versions then it is likely that different partners can implement this enhancement. The individual countries can create and activate their own implementation. In the enhancement definition, all the methods created in the enhancements interface need to have filter value as their importing parameter. The application program provides the filter values for the implementation method. Filter dependent BAdi is called using one filter value only, it is possible to check active implementation for the filter value using the function module SXC_EXIT_CHECK_ACTIVE.

Multiple use Badi


1. 2. There are multiple use and single use Business Add-ins. This option can be choose at Business Add-in definition. The distinction is base on the procedure or event character of an enhancement. In the first case the program waits for the enhancement to return a return code. Typical example is benefit calculation in HR depending on the implementation, alternative calculations can be executed. In case of multiple use add-ins, an event that may be interest to other components in program flow. Any number of components could use this event as a hook to hang their own additional actions on to. There is no sequence control for multiple-use implementations of BAdis. Sequence control is technically impossible, at the time of the definition the interface does not know which implementations parameters will be change the implementations.

3.

4. The concept of multiple use of the Business Add-in is that has been implemented once already can be implemented again by right of the software chain.

Business add-ins are enhancements to the standard version of the system. Business Add-In is a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP system based on specific user requirements. 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 In order to enhance a program, a Business Add-In must first be defined Subsequently two classes are automatically generated: An interface with IF_EX_ inserted between the first and second characters of the BADI name. An adapter class with CL_EX_ inserted between the first and second characters of the BADI name. The Application developer creates an interface for this Add-In. There are multiple ways of searching for BADI. Finding BADI Using CL_EXITHANDLER=>GET_INSTANCE Finding BADI Using SQL Trace (TCODE-ST05).

Finding BADI Using Repository Information System (TCODE- SE84). 1. Go to the Transaction, for which we want to find the BADI, take the example of Transaction VD02. Click on System->Status. Double click on the program name. Once inside the program search for CL_EXITHANDLER=>GET_INSTANCE. Make sure the radio button In main program is checked. A list of all the programs with call to the BADIs will be listed. The export parameter EXIT_NAME for the method GET_INSTANCE of class CL_EXITHANDLER will have the user exit assigned to it. The changing parameter INSTANCE will have the interface assigned to it. Double click on the method to enter the source code.Definition of Instance would give you the Interface name. 2. Start transaction ST05 (Performance Analysis). Set flag field "Buffer trace" Remark: We need to trace also the buffer calls, because BADI database tables are buffered. (Especially view V_EXT_IMP and V_EXT_ACT) Push the button "Activate Trace". Start transaction VA02 in a new GUI session. Go back to the Performance trace session. Push the button "Deactivate Trace". Push the button "Display Trace". The popup screen "Set Restrictions for Displaying Trace" appears. Now, filter the trace on Objects: V_EXT_IMP V_EXT_ACT Push button "Multiple selections" button behind field Objects Fill: V_EXT_IMP and V_EXT_ACT All the interface class names of view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for BADI class interfaces. The BADI name is after the IF_EX_. So the BADI name of IF_EX_CUSTOMER_ADD_DATA is CUSTOMER_ADD_DATA 3. Go to Maintain Transaction (TCODE- SE93). Enter the Transaction VD02 for which you want to find BADI. Click on the Display push buttons. Get the Package Name. (Package VS in this case) Go to TCode: SE84->Enhancements->Business Add-inns->Definition Enter the Package Name and Execute. Here you get a list of all the Enhancement BADIs for the given package MB. Have a look at
http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm http://support.sas.com/rnd/papers/sugi30/SAP.ppt http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm http://members.aol.com/_ht_a/skarkada/sap/ http://www.ct-software.com/reportpool_frame.htm http://www.saphelp.com/SAP_Technical.htm http://www.kabai.com/abaps/q.htm http://www.guidancetech.com/people/holland/sap/abap/ http://www.planetsap.com/download_abap_programs.htm http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3430

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3506 https://www.sdn.sap.com/irj/sdn/thread?threadID=11927&tstart=0 http://www.sap-img.com/abap/business-add-in-you-need-to-understand-abap-oo-interface-concept.htm http://www.sap-img.com/abap/difference-between-badi-and-user-exits.htm http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm Hope this resolves your query.

Вам также может понравиться