Application Development 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: 

Filters in BADI?

Former Member
0 Kudos
2,311

Hi,

can any one give some document and examles for filters in BADI.

thanks,

raja

4 REPLIES 4

Former Member
0 Kudos
453

Hi Raja,

Implementing a Classic BAdI

A list of the classic Business Add-Ins available in your system can be found either in the SAP Reference Implementation Guide (IMG) or in the component hierarchy. BAdI definitions are included in the IMG so that the customer/partner can create suitable, company-specific implementations.

In the SAP Reference IMG, BAdI implementations - in addition to BAdI definitions - can be provided. This would be suitable in cases where you can see in advance which functions are required by the customer. Using a BAdI implementation, the customer/partner can simply switch the delivered implementations on or off, as required. In the SAP Reference IMG, choose Execute in front of the name of the BAdI implementation. The icon serves as a switch for activating and deactivating the implementation.

Starting from the name and the documentation of the enhancement, you can create an implementation. During the implementation, the system creates a class that implements the enhancement’s interface. The implementation is a separate transport object and lies within the namespace of the person or organization implementing it.

For the example given here, you are to create an implementation for the string conversion. You need to program the interface method in such a way that, when the add-in is called from the application program, the string is actually converted in the way the add-in user wants it.

To create an implementation, proceed as follows:

...

1. In the SAP menu, choose ABAP Workbench ® Utilities ® Business Add-Ins (transaction SE19) or double-click the corresponding activity in the Implementation Guide (IMG).

2. Enter a name for the implementation and then click the Create pushbutton.

3. Enter the name of the add-in you want to create an implementation for in the dialog box that appears.

4. Enter a short text describing your implementation on the following screen.

5. Choose the Interface tab.

6. Choose ABAP Code as the implementation type.

Besides ABAP Code, there is also the Formula option. If you choose Formula, the content of a method is determined using the Formula Builder. For more information on this, refer to the section Implementing Methods Using the Formula Builder.

7. Navigate to the Class Builder by double-clicking the method. You must first enter a package before the Class Builder is displayed.

8. Insert the desired source code for the implementation between the method if_ex_businessaddin~method. and endmethod.statements that already exist.

Relating to our example, you could enter the statement translate parameter to upper case.

9. Save your entries and return to the Change Implementation screen.

10. Choose Activate. You may now use this implementation when the application program is executed.

Several implementations may exist for a Business Add-In that is not used on a multiple basis. However, only one implementation can be active at any one time.

What is also important is that you must declare the instance generation of the implementing class (Attributes tab) as public and not as private, protected, or even abstract. If you do this, the system will return short dumps at runtime.

Definition of a Filter-Dependent Classic BAdI

To define a filter-dependent Business Add-In, first create the definition of the Business Add-In and select the Filter-dependent checkbox.

Enter the data element you want as a filter type or select a filter type using the input help.

A filter type can be a data element or a structure. A data element must fulfill the following criteria:

• The data element's domain may contain a maximum of 30 characters and must be of the type Character.

• Either the data element has 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 domain has fixed domain values or a value table containing a column with the same type as the data element.

If necessary, you can create such a data element yourself.

If you want to call the implementation of a Business Add-In to depend not only on a filter value but on various values, you can enter the name of a structure in the FilterType field. The structure can consist of several data elements that fulfill the above conditions for data elements. The structure must not be longer than 80 characters.

You can use different elements as filter types, for example: a country, a material, an object type, an internal parameter, and so on. This also applies to structures.

Now create an interface with methods Remember that for each method you create in the interface of a filter-dependent enhancement, the filter value must be defined as the importing parameter so that the application program can provide the filter value to the enhancement method. The method then selects the active implementation for that value.

The filter value is always declared using the parameter flt_val and is predefined in the list of parameters.

kindly reward if found helpful.

cheers,

Hema.

Former Member
0 Kudos
453

Hi Raja,

Filter dependence for BADI definitions means that each interface method automatically has an importing parameter FLT_VAL assigned ot it. This parameter must be filled with a filter value as current parameter when it is called.

A BADI definition should be marked as filter-dependent whenever the characteristic of the BADI implementation should match the characteristics of the filter type - that is, whenever the implementation of different filter values should be different or should only exist at all for certain filter values.

Typical filter types are line of industry or country.

Steps to be followed for setting a filter to BADI:

just go to se18 and give ur BADI name..

then Select 'Attributes' Tab ,there u will find option Filter-Dependent in window named "type"..

check tht filter dependent checkbox and give ur data element/field in the Filter type field say u can give 'MOLGA' ..save and come back..

now go to se19 and implement this BADi and there u can give filter values for filed MOLGA..

i hope this will help..

Reward points if found helpful.....

cheers,

Hema.

Former Member
0 Kudos
453

hi,

Start the Object Navigator (SE80).

2. Open an enhancement spot. For more information, see Creating, Editing, and Deleting Enhancement Spots.

3. Select the Enh. Spot Element Definitions tab page.

4. Choose Create BAdI.

A dialog box appears.

5. Enter a name and a short text for the BAdI.

BAdIs are in the same namespace as global data types from the ABAP Dictionary, global classes, or interfaces. For BAdIs, we recommend using the prefix “BADI_” (or “ZBADI_”, and so on, in the customer namespace).

The new BAdI appears as a node in the tree display of the tab page.

6. On the right-hand side of the page, do the following:

a. Enter the attribute for multiple use.

b. Enter the instance creation mode.

c. Enter the attribute for internal SAP BAdIs (only SAP internal use).

d. Optional: Enter a Fallback Class.

e. In the tree, expand the BAdI and choose the Interface node. Enter the name of an existing BAdI.

7. Optional: Choose the function Create Filter to create a filter.

Here you can:

a. Enter the filter name, filter type, and description.

b. Optional: If you choose Constant Filter Value During Call, you may only specify a constant value at the respective filter when using GET BADI. This is provided for future performance improvements of the statement.

c. Optional: Enter either a data element or a domain with fixed values, or a search help. Alternatively, enter a check or input help class, and a length (together with decimal places). In this way, the filter values specified at GET BADIcan be checked during the BAdI implementation.

8. Optional: Choose the function Create Screen Enhancement in order to create the BAdI as a screen enhancement.

The BAdI must not be of a multiple use type.

...

a. Enter Calling Program, Screen Number, Subscreen Area, and Description.

b. Optional: Select Default Value to specify a screen of a program that is used if no active implementation is found at runtime.

9. Optional: Choose Create Function Code Enhancement to create the BAdI as a function code enhancement.

refer to the following link for more information

http://abapprogramming.blogspot.com/2007/09/badi-3.html

pls reward points if helpful,

shylaja

The BAdI must not have any filters and must not be of the type for multiple use.

a. Enter Program, Function Code, and Description.

b. Optional: Select Default Value to specify an icon, a menu text, a pushbutton text, and a quick info, all of which are used when no active implementation is found at runtime.

10. Optional: Create an example implementation.

a. Select the BAdI, and choose Create Example Class from the context menu.

b. Enter the name of a BAdI implementation class and a description.

Former Member
0 Kudos
453

Hi Raja,

Filters represent the conditions that message types and BAPIs have to satisfy so that they can be distributed by ALE outbound processing.

Message types and BAPIs can be filtered using the following filter types:

· Filter Objects:

With BAPIs the filter object type corresponds to a parameter name. BAPI filter objects check whether a parameter contains the specified object value. An IDoc is created and distributed via the BAPI, only if this is the case.

The following distinction is made:

Receiver determination

When the receiver is determined, the filter objects are checked against the specified conditions and the valid receivers are reported back.

Parameter Filtering

The dataset of the BAPI tables is determined by filtering the BAPI table parameters, similar to filtering IDoc segments

· Classes

. Dependencies

Dependencies describe the distribution relationship between the interfaces below:

Between BAPIs

Between message types

Between a BAPI and a message type

Example of dependency between a BAPI and a message type:

The distribution of company addresses has been integrated in the object maintenance for the vendor. The address data is then distributed together with the object data via ALE. The address data is dependent on the object data and is distributed via the BAPI. The object data is distributed in the message type CREMAS.

So a dependency exists between the BAPI and the message type.

In the distribution model an active receiver filter is assigned to the BAPI used for distributing organization addresses (AddressOrg.SaveReplica). The dependency has been activated in the attribute Dependent distribution in the filter display.

Based on the receiver determination, the object data with the BAPI addresses are only distributed, if the filter condition for CREMAS is met.

Reward if helpful.

Thankyou,

Regards.