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

Step by Step Guide On BADI With Filter Implementation

1. To implement filters for a BADI, first deactivate all existing implementations of that BADI. Then modify the BADI definition to make it filter-dependent and select a data element as the filter type. 2. When the BADI definition is saved and activated with a filter, the system will adjust existing implementations to include the new filter parameter. 3. Filters allow controlling which implementation is triggered based on the filter value passed during runtime. If the passed value matches the value defined for an implementation, then that implementation will execute.

Uploaded by

kvvsmbalaji
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Step by Step Guide On BADI With Filter Implementation

1. To implement filters for a BADI, first deactivate all existing implementations of that BADI. Then modify the BADI definition to make it filter-dependent and select a data element as the filter type. 2. When the BADI definition is saved and activated with a filter, the system will adjust existing implementations to include the new filter parameter. 3. Filters allow controlling which implementation is triggered based on the filter value passed during runtime. If the passed value matches the value defined for an implementation, then that implementation will execute.

Uploaded by

kvvsmbalaji
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 26

Step by Step guide on BADI with Filter implementation

By Vijayendra Krishnamurthy Rao, Hewlett-Packard

Step 1  Before implementing filter objects to a BADI. We need to deactivate all the implementation for
that BADI.

Go to SE18 (BADI definition) and from there navigate to all BADI implementation to view all the active
implementations for that BADI.
Select the BADI implementations listed on the screen and deactivate the implementation. Once
done, return back to the initial screen of SE18 and proceed with next step.

Step 2  go to SE18 – BADI Definition screen and change the existing BADI definition that we created in
the earlier tutorial.
Select the FILTER –DEPENDENT check box under the TYPE section. This will open up the FILTER
TYPE field for inputs.

And do an F1 on the FILTER TYPE field.


Click on the F4 on the FILTER TYPE field name and enter some search criteria to find a relevant data
element.
And click on the continue button
Select the data element from the list to set up your filter and hit enter.

Click on the save button and active the BADI definition.

If a BADI implementation already exists then the system will try to adjust the implementations since the
definition of the BADI has been changed (This step will be required only if you have not deactivated the
implementations as explained in the first step).
Click on the continue button.

Click on continue to proceed

Now to ensure that the interface parameters have been adjusted by the system click on the interface tab
and then double click on any method to see the list of parameters.
As seen from the above screen the system has added a new parameter. You can now use this filter in the
code to trigger your logic conditionally.

Similarly it will also adjust the other methods defined in the interface. Since in the implementation part the
BADI interface is used the changed done in the parameters are bydefault reflected in the BADI
implementation as well.
Lets go to the implementation part and see the details.
Select the menu IMPLEMENTATION  DISPLAY.

The system will display all the implementation if it has more than one implementation.

Select the first implementation and click on the continue button.


Now click on the ATTRIBUTES tab to see the difference.
You will notice that now the implementation is capable of adding filters for the user names. You can click
on the INSERT ROW button to add any new filters.

And as you can see from the screen shot below the new parameter list is automatically available in the
implementation part.
Now lets use this filter type and make changes to the program.
We have introduced a new CHECK condition to query and check the value of the filter during runtime.
Click on the save and activate the method.

Return to the initial screen of the implementation and define a filter value by clicking on the INSERT ROW
button under the filter section. The filter value acts like a condition. Only if, during the runtime the filter
value matches the method will get executed.

Once done click on save and activate the implementation.


Similarly add filter to the other implementation and save and activate.
As seen from the above we have used a different user name in the other implementation. So this means
that the first implementations will execute for user SAPUSER and the second implementation will be
executed for the other user SAPUSER1. This is the main functionality of the Filters in the BADI’s you can
control when a BADI should be triggered in the system.

We need to make changes to the program in order to reflect the newly created filter.

Comment the existing call of the instance method and Call the instance method again using the
PATTERN.
As seen above the second call to the method has the additional filter parameters FLT_VAL.

Pass appropriate values to the parameters and once done with changes save it and activate the program
for testing.

Before testing place a breakpoint on each of the implementations to see which one gets triggered in what
sequence.

Execute the program and check if its stops at the breakpoint.


As seen from above it triggers the first IMPLEMENTATION of the BADI the reason being we passed the
filter value SAPUSER and we defined the filter value as SAPUSER in the implementation screen. So
since these two values match the system triggered the first implementation and the execution stops at
breakpoint place in the method.

Now since we are using the filter value passed by the program and as the above check fails the execution
will come out without executing.
now if you hit F7 to proceed to the next execution you will notice that the execution has returned back to
the program.
The simple reason being the second implementation filter check failed. That means that we are passing
the filter value SAPUSER from the program and inside the Implementation we have added the filter as
user SAPUSER1. So since the filter value does not match the system does not trigger the second BADI
implementation and hence there is no output.
Now lets make one change in the FIRST BADI IMPLEMENTATION. We will remove the check we had
introduced in the code.
We have commented the line as shown above. Lets execute the program again and see the system
behavior.
Now if you see from above, the FIRST IMPLEMENTATION has triggered as the value of the FILTER
passed from the program and the value of the FILTER maintained in the Implementation section
matches.

But it does not trigger the SECOND IMPLEMENTATION as the value of the filter passed from the
program does not match the value of the FILTER maintained in the implementation section.
Now lets change the calling program and change the filter value such that it DOES not trigger the FIRST
IMPLEMENTATION but triggers the SECOND IMPLEMENTATION.
Now we are passing the filter value as SAPUSER1 instead of SAPUSER. Now when we execute the
program the system should trigger only the SECOND IMPLEMENTATION of the BADI and not the first
one. Lets execute the program and confirm this

As seen above the system does not trigger the first implementation but it directly triggered the SECOND
IMPLEMENTATION as the value of the filter passed by the program and the value of the filter maintained
in the implementation section matches.

And we can see the new output.


This how we can use the filters to control the way a BADI should trigger. This is very useful concept
introduced by SAP for customer enhancements.

You might also like