Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

creatign a custom badi

Former Member
0 Likes
1,311

hai freinds i want to create a custom badi, i am doing through se18 and giving zdemo and create but it gives error that create option is possible for enhancment spots only can any one help me how to create the custom badi

regards

afzal

hai freinds i want to create a custom badi, i am doing through se18 and giving zdemo and create but it gives error that create option is possible for enhancment spots only can any one help me how to create the custom badi

regards

afzal

3 REPLIES 3
Read only

Former Member
0 Likes
783

Business Add-Ins

Overview

BAdi Definition

BAdi Implementation

Calling BAdi

Filter Dependent Badi

New SAP enhancement technique

To accommodate user requirements not available / too specific to be included in the SAP standard Program

Based on ABAP Objects – It has Interfaces & Methods

Guaranteed 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

Though different enhancement technique, BAdi has following distinct features

-Uses Object oriented approach

-Two parts - Definition and its Implementation - definition can either be SAP provided or user may also create it

-no longer assumes a two-system infrastructure (SAP and customers)

-allows multiple levels of software development (by SAP, partners, and customers, and as country versions, industry solutions, and the like)

-Can have multiple representations – specific one will be executed based on some criteria (filter)

-No SSCR registration

Application Programmer defines an interface for the Business Add-Ins

Enhancement management takes this interface & generates an adapter class for implementing it, thus opening path for implementation

As per need, BAdi is suitably implemented

Developer then creates an instance of the adapter class in the application program and calls the corresponding method at the appropriate time

Application program simply calls the adapter class methods; it does not know which implementations are actually being called

Adapter class methods generated by add-in management decide which implementation is to be called

Look for BAdi in IMG and in component hierarchy

Create own implementation of the add-in (complete coding for Methods) and activate

Enhancement's active components are called at runtime.

BAdi Definition

To include Business Add-Ins in the program

- Define an interface for the enhancement in the SAP menu under Tools-> ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE18)

-Call the interface at the appropriate point in application program

-Customers can then select the add-in and implement it according to their needs

Let’s plan a simple task:

We want to convert strings in your application program is a specific way through Business Add-Ins technique

As the application developer, first task is to define an enhancement consisting of an interface & a method with a changing parameter to transfer value

Choose Tools ->ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE18) from the SAP menu

Create a new Business Add-In containing a maximum of 20 characters and move to Interface Tab

Name of the interface is proposed by the system but may be changed

Save and double-click on the interface name to add a method

System branches to the Class Builder

Assign a method to the interface (default is Instance Method)

Add a parameter

Save and Activate

Definition screen(SE18) will now contain the method assigned to the interface

Documentation may be created to describe the intended functionality of this Add-Ins

BAdi Implementation

ABAP Workbench ->Utilities -> Business Add-Ins (transaction SE19)

Find the suitable Business Add-Ins present in system (Use IMG or Component hierarchy)

Use Add-Ins Documentation to understand functionality & to decide

Implement the Add-Ins

-a class is created with the same interface

-Finalize coding for the method

Implementations are discrete transport objects and lie within the namespace of the person or organization implementing them

Work on Simple Badi project – Continued…

Already structure of the interface defined

In order to create an implementation for the text conversion example, the add-in (in this case, the interface's method) needs to be filled with logic that converts the string. This logic will be run through every time the add-in is called from the application program

Choose ABAP Workbench ->Utilities -> Business Add-Ins (transaction SE19)

Create a new implementation and select the appropriate definition in the dialog box

Add a short text and move to Interface tab

Save

Double-click the method name when the system will take you to the code window for the method

Insert the desired source code for the implementation between the method if_ex_businessaddin~method. and endmethod. statements automatically provided to you by the system.

Save and return to the Change Implementation screen

On Activation, this implementation may be executed from the application program

Sample code to call Add-In from ABAP Program

To call static method of a global class directly, class … definition load statement is needed

Instance of the Adapter class is created and its method is executed

If enhancement needs to be different based on some parameter (e.g. country-specific or company-code specific), separate implementation of the same Add-In can be created and activated

At run time, the specific implementation will be execute

Possible through Filter-Dependent Badi

How it works

-Switch on Filter-dependency while defining the interface

-Select a suitable filter element

-All methods created in the interface will have filter 'FLT_VAL' as one import parameter

-Application program provides the filter value to the enhancement method

-The method then selects the active implementation for that value

What qualifies as a Filter

A Data element

Underlying domain may contain a maximum of 30 characters and must be of Character type

The data element must

-Either have a search help with a search help parameter of the same type as the data element and this parameter must serve as both the import and export parameter or

-the element's domain must have fixed domain values or a value table containing a column with the same type as the data element

Custom data element with the criteria may also be used

Implementing a Filter-Dependent Business Add-In

Implement the Add-In for each relevant filter value

However, multiple filter values may use the same implementation

Enter a characteristic filter value for the implementation

Calling a Filter-Dependent Business Add-In

Same as before

Pass the filter value as export parameter to the method

BAdi – some useful information

There can be more than one implementations of the same BADI definition, and in that case only the active implementations will be executed

You can activate or de-activate any of the implementations after creation

Enhancement, interface, and associated classes generated all lie in the appropriate application development namespace

Business Add-In implementations lie in the respective namespaces of the people who created them

Changes made to the interface and changes made to the Business-Add-In definition are always incompatible

-If implementations already exist for a Business-Add-In definition, they are invalidated if you make changes to the interface. This means that their syntax is no longer correct. No statements can be given on the runtime behavior. Avoid making changes to the interface or the Business-Add-In definition after the transport has taken place.

-If changes to the interface are inevitable, navigate to the Class Builder for all implementing classes and clean up the method includes of these classes (Utilities > Clean up > Method includes)

Please give me reward point If it is useful

Thanks

Murali Poli

Read only

Former Member
0 Likes
783

Afzal,

Check this link to create your own BADI.

Regards

Aneesh.

Read only

Former Member
0 Likes
783

hii