0% found this document useful (0 votes)
30 views27 pages

Kernal Vs Classic Badi

The document provides a detailed guide on creating a Fallback Class in a BAdI (Business Add-In) using SAP's SE18 and SE20 transactions. It outlines the steps for creating an enhancement spot, BAdI definition, interface, and fallback class, as well as implementing the class and calling the BAdI in an application. The fallback class serves as a default implementation when no suitable BAdI implementations are found, ensuring the application can still run without errors.

Uploaded by

dipnar6379
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)
30 views27 pages

Kernal Vs Classic Badi

The document provides a detailed guide on creating a Fallback Class in a BAdI (Business Add-In) using SAP's SE18 and SE20 transactions. It outlines the steps for creating an enhancement spot, BAdI definition, interface, and fallback class, as well as implementing the class and calling the BAdI in an application. The fallback class serves as a default implementation when no suitable BAdI implementations are found, ensuring the application can still run without errors.

Uploaded by

dipnar6379
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/ 27

SE20:

One more example:

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 the 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

Another Example 2:
Scenario: For a BADI definition if some BADI Implementations are exist then all the active BADI
implementations are called during run time. If all the BADI implementations are inactive or does not
exist then if there is any fallback class exist then it is called during runtime. The FALLBACK class is a
default implementation of BADI definition which is called if all the BADI implementations are inactive
or none of the BADI implementation exists.

Step1. Go to TCODE-SE20. Create a Enhancement Spot.


Step2. Provide a Enhancement spot name and click on the Create button.

Step3. Provide a short text and click on the continue button.

Step4. Save in local object.


Step5. Create a BADI definition. Activate the enhancement spot and click on the create button to
create a BADI Definition.

Step6. Provide the BADI definition name and the description and at last click on the Continue button.
Step7. Some of the BADI definition properties are Multiple use.

Step8. Expand the BADI definition, click on the Interface element from the left hand side. Then
provide the Interface name 'ZIF_SHOW_MESSAGE' in the right hand side and then double click on it.
A popup will appear stating to create the same . Click on YES button to create it.
Step9. Now provide a method description and activate it and go back.

Step10. Activate it.

Step11. Create a BADI Implementation. Expand the BADI definition in the L:H:S. Select the
Implementation and click on the highlighted button to create the implementation.
Step12. Now provide a Enhancement implementation name and description and click on the continue
button.

Step13. Now provide the BADI Implementation name, description and the implementing class name
and click on the continue button.

Step14. Now expand the BADI implementation form the L:H:S and click on the Implementing class to
implement the method.
Step15. Now double click on the Method Name to implement it.

Step16. click on YES to continue.

Step17. Provide some in the method and activate it. At last click on the BACK button .
Step18. Now one BADI implementation is created for the BADI definition.

Step19. Go to SE38 to create a report and calling the BADI implementation. Provide the Report name
and click on the Create button.

Step20. Provide the below code. activate it and RUN it.


Step21. The Active Implementation is called.

Step22. Go to the BADI implementation .

Step23. Deselect the check box and activate the Enhancement implementation.
Step24. Now again run the program.

Step25. The output is as shown below. As the BADI implementation is inactive.

Step26. Now go to the BADI Definition.


Step27. Select the check box and provide a fall back Class name and double click on it. From the
popup click YES to continue.

Step28. Now double click on the method to implement it.


Step29. Provide some statement and activate it. At last click on BACK button.

Step30. Now activate the class and go back.

Step31. After this the Enhancement spot is inactive.


Step32. Activate the enhancement spot.

Step33. Run the Report.


Step34. The output is as shown below. As the BADI implementation is Inactive and the FALLBACK
class is exists.

Step35. Go to the BADI implementation and activate it again by selecting the check box.

Step36. Now run the report.


Step37. The output is as shown below.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy