Step by Step guide on BADI with Filter implementation - Sap 4 All

Latest

Please enter your email and get the updates in your inbox.

Sunday, 29 May 2016

Step by Step guide on BADI with Filter implementation

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.

14 comments:

  1. Thanks for sharing this Information, Got to learn new things from your Blog on SAP SF.
    SAP SF
    Call us at eight one two two two four one two eight six.

    ReplyDelete
  2. Thanks for sharing this Information,

    Got to learn new things from your Blog on Sap abap.

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    Both online and classroom training is provided.

    Contact 8122241286

    ReplyDelete
  3. I simply want to tell you that I’m all new to blogs and truly liked you’re blog site. Very likely I’m likely to bookmark your site .You surely come with remarkable articles. Cheers for sharing your website page.

    SAP HR Training in Chennai

    SAP SD Training in Chennai

    SAP Basis Training in Chennai

    ReplyDelete

  4. Thank you for giving this best information. It’s a very nice topic
    SAP EWM Online Access

    ReplyDelete
  5. Appreciate you sharing, great article.Much thanks again. Really Cool.
    sap wm training
    sap wm online training

    ReplyDelete
  6. Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download Now

    >>>>> Download Full

    Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download LINK

    >>>>> Download Now

    Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete
  7. Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download Now

    >>>>> Download Full

    Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download LINK

    >>>>> Download Now

    Step By Step Guide On Badi With Filter Implementation - Sap 4 All >>>>> Download Full

    >>>>> Download LINK qQ

    ReplyDelete