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.

3. 2. Enter a name for the BAdI Interface. Deselect thee Multiple Use check box.3. Expand the BAdI node and click on the Interface as shown below.4.2. The new BAdI appears as a node in the tree display of the tab page. . A dialog box appears. 3.2. 2. 3.1. 2.2. 3. Create a Interface: Methods are defined in the interface which determines what use you can make of your BAdI. Enter a name and a short text for the BAdI Definition.

Note: We have created a single use BAdI.3. Now define parameters for the method as shown below.7. 3. 4.6. Go back to Enhancement spot screen. Now if we the run the Application Program it dumps because there should be one active implementation for a single use BAdI. Press Enter or Click on change icon. 3.3. 3. Define a method. 3.4.5. Save and activate the BAdI Interface and Enhancement spot.  Use a Fallback Class. Create a Fallback Class: . We can handle this in two ways:  Catch the exception CX_BADI_NOT_IMPLEMENTED.

Enter a name for the Class. 4.2. The method of the BAdI interface is already defined.Call fallback class if no implementation is executed 4.1. Enter a name for the Fallback Class and press enter. Select the checkbox . 4. . Press Enter or click on change icon it will take us to class builder.The Fallback option is used if no BAdI implementation with suitable filter conditions and no standard implementation are found.2.3. 4.

Calling BAdI in the Application: After the BAdI definition and implementation.. To Implement Class double click on the method Z_IF_BADI_FALLBACK~ADD.. BAdIs can be called using a combination of the ABAP statements GET BADI and CALL BADI.......... Implement Class: 5.. 5..4. DATA: w_handle TYPE REF TO zbadi_fallback_def.. " 300 WRITE: 'RESULT:'.....6... . result = value1 + value2........ 5.. * CALL BADI ..  GET BADI – for getting objects  CALL BADI – for calling interface methods * Parameter Declaration........ 6. 5. GET BADI w_handle..for getting objects.... PARAMETERS: p_value1 TYPE i. p_value2 TYPE i........... * GET BADI .4... * Data Declaration. Save and activate the Implementation.....2..1.... Write the below code in method... Save and activate the interface. w_result..... 7..... CALL BADI w_handle->add EXPORTING value1 = p_value1 " 100 value2 = p_value2 " 200 IMPORTING RESULT = w_result.......... w_result TYPE i.... Result: Execute the Application.for calling interface methods...

The traditional way of doing code modifications was via User exits. at the Database layer you could append structures to the existing SAP structures. at the Presentation layer you had Field Exits. menu and screen enhancements into a single add-in. At the Application layer you had Program exits.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 . 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 . As per SAP's 3 Tier Architecture. Screen Exits and Menu Exits.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. 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.

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.- 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. Screen enhancements can be implemented for these in the form of sub screen screens. o By instantiating the adapter class in the application program. . o Screen Enhancements: Sub screen areas can be entered for a Business Add-In. 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. its corresponding methods can be used BADI Enhancement options o In the business Add INS.

Sign up to vote on this title
UsefulNot useful