Understanding and Implementing Classic BADI
- SAP has provided us a class CL_EXITHANDLER for classical BADI purpose.
- We will use GET_INSTANCE method of CL_EXITHANDLER class to find the classic BADI for our requirement.
Let’s take a requirement to understand it more clearly :-
Requirement :-
-
While creating a material through MM01 transaction code,
- The Customer wants that if I am providing basic unit of measure as KG then I should get a error, when I click on save button.
Ways to find a Classical BADI :-
- There are mainly three ways to find a Classical BADI , I will discuss the first one here and then I will discuss the rest of the two in the next part.
- In this part, we will find our required Classical BADI through debugging.
Finding Classical BADI for the above requirement :-
-
Step 1 :- Go to SE24 transaction code and display class CL_EXITHANDLER → double click on GET_INSTANCE method.
- Put a debugger as shown above.
-
Step 2 :- Now go to mm01 transaction code for our requirement.
-
Step 3 :- Click on save button → It will take you to the debugging mode.
-
Step 4 :- Whatever BADI is available in this program, you get in the variable EXIT_NAME, you just need to keep pressing F8.
Note :-
- Whatever BADI you will get here, you need to go to SE18 and check the BADI that it fits to your requirement or not.
-
Step 5 :- For the above requirement, the suitable BADI is given below.
-
In this BADI_MATERIAL_CHECK we have a dedicated method which we will use for our requirement.
-
Implementing Classic BADI for our requirement :-
-
Step 1 :- Go to SE19 transaction code and select Classic BADI radio button.
-
Step 2 :- Pass the name of the BADI that we have found above in the debugging and click on create button.
- Provide a implementation name for our BADI.
-
Step 3 :- Click on the interface tab → The name of the implementing class will be appeared automatically.
-
Step 4 :- Double Click on the implementing class.
-
Step 5 :- Double click on the check data method to write the logic.
-
Step 6 :- In this method we have a table WMEINH, where we will find the entered basis unit of measure from MM01 screen, So, We can write our logic here.
- Now, go back to BADI and activate the BADI first.
Testing the Implementation :-
-
Go to MM01 transaction code and fill the details.
-
Press enter and fill the rest of the details.
-
Click on save button.
- We got the error message.
Note :-
-
After practice, always go back to the BADI and deactivate the BADI.
Comments
Post a Comment