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

Fallback class in a BADI

By Syed Abdul Adil, YASH Technologies Fallback Class: The Fallback option is used if no BAdI implementation with suitable filter conditions and no standard implementation are found. 1. Create a simple Enhancement spot: 1.1. Go to Transaction SE18 and Create an Enhancement spot.

1.2. A dialog appears. 1.3. Specify a name of Enhancement spot and a short description. Optionally, you can assign the new spot to an already existing composite enhancement spot.

1.4. Save and activate the new simple Enhancement spot. 2. Create a BAdI definition: 2.1. Now create a BAdI within the Enhancement spot, click on create BAdI definition icon as shown below.

2.2. A dialog box appears. 2.3. Enter a name and a short text for the BAdI Definition.

2.3. The new BAdI appears as a node in the tree display of the tab page. 2.4. Deselect thee Multiple Use check box.

3.

Create a Interface: Methods are defined in the interface which determines what use you can make of your BAdI. 3.1. Expand the BAdI node and click on the Interface as shown below. 3.2. Enter a name for the BAdI Interface.

3.3. Press Enter or Click on change icon. 3.4. Define a method.

3.5. Now define parameters for the method as shown below.

3.6. Save and activate the BAdI Interface and Enhancement spot. 3.7. Go back to Enhancement spot screen. Note: We have created a single use BAdI, Now if we the run the Application Program it dumps because there should be one active implementation for a single use BAdI. We can handle this in two ways: Catch the exception CX_BADI_NOT_IMPLEMENTED. Use a Fallback Class. 4. Create a Fallback Class:

The Fallback option is used if no BAdI implementation with suitable filter conditions and no standard implementation are found. 4.1. Enter a name for the Fallback Class and press enter. 4.2. Select the checkbox - Call fallback class if no implementation is executed 4.3. Enter a name for the Class.

4.2. Press Enter or click on change icon it will take us to class builder. The method of the BAdI interface is already defined.

4.4. Save and activate the interface. 5. Implement Class: 5.1. To Implement Class double click on the method Z_IF_BADI_FALLBACK~ADD. 5.2. Write the below code in method.
result = value1 + value2.

5.6. Save and activate the Implementation. 6. Calling BAdI in the Application: After the BAdI definition and implementation, BAdIs can be called using a combination of the ABAP statements GET BADI and CALL BADI. GET BADI for getting objects CALL BADI for calling interface methods * Parameter Declaration.............................. PARAMETERS: p_value1 TYPE i, p_value2 TYPE i. * Data Declaration....................................... DATA: w_handle TYPE REF TO zbadi_fallback_def, w_result TYPE i. * GET BADI - for getting objects.................. GET BADI w_handle. * CALL BADI - for calling interface methods. CALL BADI w_handle->add EXPORTING value1 = p_value1 " 100 value2 = p_value2 " 200 IMPORTING RESULT = w_result. " 300 WRITE: 'RESULT:', w_result. 7. Result: Execute the Application.

Result : 300

After completing this document you will be able to,

Understand what Business Add In's (BADIs) are Define BADIs Implement BADIs Use BADIs Create an implementation for an existing SAP BADI Create Multiple Use BADIs Create Filter Dependent BADI Introduction Traditional way of doing code modifications - Exits 3 Tier Architecture For Presentation Server Field Exits Screen Exits Menu Exits For Application Server Programs -> Program exits -> call customer function -> Include At Database Level Table -> SE11 -> Go to -> Append Structure With BAdIs you can make changes only at the Application Layer. The traditional way of doing code modifications was via User exits. As per SAP's 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. BADI's Business Add-Ins is a new SAP enhancement technique based on [[ABAP Objects]] They can be inserted into the SAP system based on specific user requirement 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 :

o o o
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 :

o An interface with 'IF_EX_' inserted between the first and second characters of the BAdI name o An adapter class with 'CL_EX_' inserted between the first and second characters of the BAdI name. o The Application developer creates an interface for this Add-InEnhancement management generates an adapter class for implementing the interface o This opens a path for custom implementations to be created by partners or customers. o By instantiating the adapter class in the application program, its corresponding methods can be used BADI Enhancement options o In the business Add INS, all the components of an options are grouped together o Program Enhancements: Functional enhancements of the program are defined in the form of interface methods and can be used with or without Menu Enhancements or Screen Enhancements o Menu Enhancements: Function codes can be entered for a BADI for the corresponding menu entries in the user interface definition. o Screen Enhancements: Sub screen areas can be entered for a Business Add-In. Screen enhancements can be implemented for these in the form of sub screen screens.

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