Sie sind auf Seite 1von 13

BADI EXAMPLE: A simple Business Add-in, which is going to raise a message when

you change the unit of measure in MM02.

Transaction codes: SE18->Business Add-in definition


SE19->Business Add-in implementation
Step 1. Go to MM02 to get the package name.

Its going to display the status, double click the screen program name. Get the package
from Goto -> Attributes.

Step 2. Goto the Transaction code SE18. Press F4.


Step 3. Press the Pushbutton Information Systems.
Step 4. Give the Package name in the Package Field. Here, the package name is MGA,
which you got from the status screen of MM02.
Step 5. Press Enter, Its going to show all the Business Add-in Definitions available in that
particular package.
Step 6. Here the Business Add-in BADI_MATERIAL_CHECK does the work for us.
Double click it.
Step 7. Press the Display button.
Step 8. It will go to the initial screen display of the Business Add-in.
Step 9. Press the Interface Tab. It will display the methods available in that interface.

Whats an interface?
Well, an Interface is a container that contains unimplemented methods. Thats the Point,
now we are going to implement the methods of this interface. Lets find out, of all these
methods which method does the work for us (remember, the badi implementation must
raise a message whenever the user tries to change the unit of measure in MM02
Transaction). Intuitively, CHECK_CHANGE_MARA_MEINS does the work for us.
Well if you are not convinced enough look for the description in the description part.
Step 10. Lets get into the business now, creating an Implementation of the Business Add-
in.
Step 11. Look for the Menu bar, you will find the Implementation Menu, Click it.
Step 12. Press the Create menu item.
Step 13. Its going to ask the Implementation name, Give a name and press Enter.
Step 14. Give a Short description and save it.
Step 15. Press the Interface tab. You will see the Interface name and the class that is
going to implement it.
Step 16. Double click the method CHECK_CHANGE_MARA_MEINS. The following
screen appears.
Step 17. Write the necessary code,

Sample code: IF OLD_MEINS NE NEW_MEINS

MESSAGE E000(ZMESS) WITH OLD_MEINS.

ENDIF.

Well, Whats happening here, wondering where I got these variables from. Do not worry,
I will let you know. In the previous screen shot you have seen a class that was
implementing the Business Add-in. Double click the class name, you will be lead into a
screen where all the methods of the class are shown. Place the cursor on the following
method IF_EX_BADI_MATERIAL_CHECK~CHECK_CHANGE_MARA_MEINS,
and click the Parameters Push Button which is above. You will find old_meins and
new_meins in the parameters list.

Do not forget to create a message class ZMESS with message id 000.

What is this
IF_EX_BADI_MATERIAL_CHECK~CHECK_CHANGE_MARA_MEINS?
Read the following points

1) I already told you an interface is a container of unimplemented methods. Look at


the ~ sign in the middle of the interface name and the method. That says that the
method belongs to this Interface.
2) And the class is implementing this interface.

Step 18. Save it and Go Back.


Step 19. Activate the implementation
Step 20. Voila! You have just implemented a Business Add-in.
Step 21. Go to MM02 and try to change the unit of measure of a material.

Das könnte Ihnen auch gefallen