0% found this document useful (0 votes)
1K views

Fallback Class in A BADI

1. A fallback class in a BAdI is used when no active BAdI implementation matches the filter conditions or no standard implementation exists. 2. To create a fallback class, define a fallback class name when creating the BAdI and select the option to call the fallback class if no implementation is executed. 3. The fallback class implements the interface method defined for the BAdI to provide a default behavior when no other implementation matches.

Uploaded by

pcbarryos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Fallback Class in A BADI

1. A fallback class in a BAdI is used when no active BAdI implementation matches the filter conditions or no standard implementation exists. 2. To create a fallback class, define a fallback class name when creating the BAdI and select the option to call the fallback class if no implementation is executed. 3. The fallback class implements the interface method defined for the BAdI to provide a default behavior when no other implementation matches.

Uploaded by

pcbarryos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

You might also like