The Requirement is to put a information message while creating a material if Material Group is A05 and Division is: 02.
(Why can’t we use field exit ?? : As it needs two information ( Material group and Division ) for the material also user wants information message while saving the material. this cant be achieved using field exit ).
Step 1:
How to find appropriate BADI for this requirement??
Put the break- point into Class CL_EXITHANDLER’s GET_INSTANCE method.
Go to transaction code MM01 , create a material and try to save it. it stops at many location with different values of EXIT_NAME. (After checking into Se18 we got the BADI_MATERIAL_CHECK which can be use for our requirement.
- It has a method CHECK_DATA which is called before saving the material.
- It also has WMARA table as input data (Material Group and Division comes in MARA table).

Step 2:
Go to Transaction code SE18.
Open BADI : BADI_MATERIAL_CHECK.
Go to menu option Implementation à Create.

Step 3:
Give the implementation name as ZMM_MAT_CHECK.

Step 4:
Double click on the method CHECK_DATA.If you notice the input parameters we have many data related to batch , material and storage location etc..
For our requirement we need material group and devision Which exist in WMARA.Put the below code inside the method then activate the class and method.
if WMARA-MATKL eq ‘A05′ and WMARA-SPART eq ‘02′.
message ‘Material creation for this Group should be avoided for animal products!!’ TYPE ‘I’.
endif.
This code is just checks the material group and division.

Step 5:
Go back and Activate the implementation.

Step 6:
So now it’s the time to Disco !!!!!!!Upsssss Sorry it’s the time to test this BADI.
For this go to transaction MM01 and try to create a material.
(if you are confused use material name as CH004 ,
Industry sector as Animal Health and
Material Type as Beverages )
Click on the ENTER Button and from the view select BASIC DATA 1.



















uma gupta
hi dude…
u ease my proble..
Yogesh Patil
Hi Friends,
I have total 4.5 Years of Exp. in SAP-ABAP, I gone through lot of documents but the way these document and designed and presented on this portal are amazing…comments in between like Brett Lee Bounser and It’s a time to Disco…
I mean to say apart from work there is something different which I liked most…
No doubts about Document they are really very well documented and User friendly…but to Present each and every thing you should have proper way…I appreciate this way of publishing document…
Thanks a lot…& I appreciate UR efforts…Good Job Done …Keep it up…!!!
Thanks & Regards,
Yogesh Patil
asha
really presented well…in an understanding way..:-P
Elmira
Infrotmiaon is power and now I’m a !@#$ing dictator.
rakesh
hi
i am rakesh the way of your presention is very good
superb keep it up guyes
BAdi Beginner
Like the way you presented. Light and Easy!
Kalyan
This was really helpfull …… and damn good presentation….
sai
tahking you
Rajiv Das
Awesome Presentation….I can see you in front of me, as u teaching in a light mode,..
akein
Priceleesss!!!
Nooruddin
This was really helpfull and Priceleesss!!! Thank you very much.
kevin
it ’s good to understanding the BADI, awesome
venky
Good job done!!
sanju
Hi Dear,
Can u help me out to know how to know its edit implementation of badi or create implementation. And again within dat which radio button to choose with sm examples.
Thanks
Sanju
Raj
Hi Sanju ,
Please find my comments below:
how to know its edit implementation of badi or create implementation
BADI is something is provided by SAP standard team what we do is we create an implementation for it.
You cant edit the standard BADI.What we do is we create an implementation for it and we modify the created
implementation.
And again within dat which radio button to choose with sm examples.
It’s not clear what you want to ask.may be you are asking for.Can you put some light on it.?
thanks
Raj
SAP IGnite.
venu
Good
Oka
Nice tutorial
Thanks
oka
Arumugam
Thank You very much.
Whenever I use BADI, surely I will remember you.
Thanks
my badi from you,thanks
Abhinesh Sinha
Hi,
It seems as somebody is teaching infront of me. It is presented in a very easy and understandable way. It attracts the Reader attention.
Thanks for your kind support.
ramya
hi raj,
am a hr abaper i got a requirement to set a default value for the field( id number) in infotype 185 and subtype 02, i already created a classic badi ’zhrpadooinfty’ so using this i need to set the default value, i asked my team leader he asked me to do using implict enhancement so i am unable to do please help me on this.
thanks & regards
ramya
Raj
Hi Ramya,
If your question is how to implement the implicit Enhancement :
check out : How to implement Implicit Enhancement
If the code which you have placed in the BADI is not working thn and thn follow your lead’s method.
Please paste the code which you are trying with program name so that i can check it out in my system.
thanks & Regards,
SAP Ignite
~Raj
ramya
Hi Raj,
i have return the below code in my badi (before_ouput method) *************Setting default value for field ID number in IT 185*************************
DATA: i0185 TYPE p0185.
if ipsyst-ioper = ‘INS’ and innnn-infty = ‘0185′.
CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN
EXPORTING
PRELP = innnn
IMPORTING
PNNNN = i0185.
MOVE ‘PANNOTAVBL’ to i0185-icnum.
CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP
EXPORTING
PNNNN = i0185
IMPORTING
PRELP = innnn.
endif.
for my classic badi the definition name is HRPAD00INFTY
so this what i have used can you help me on this,
Thanks & Regards
V.Ramya
Chetan
Great help! Thanks.
sharmistha
hii raj,
can u plz explain me why we chose badi_material_check.
i m new in badi.
and ur badi material helps me a lot.
if u have more material on badi plz send me on <><><>
thanks,
sharmistha.
Raj
Hi Sharmistha,
As i mentioned in the post. the BADI BADI_MATERIAL_CHECK’s Check_data method is triggered
during creation of the material .
we want when use is creating a material validation is done so the triggered timing is perfect.
Also whatever data we want to validate it contains the the importing parameter of the badi so
it can be used.
NOTE : there might be more thn one BADI who fulfill ur requirement ( triggering time , proper importing data )
You can use any badi at that time,no restriction on it as such.
Please get back if i am not clear .
Thanks
RAJ
SAP IGnite.
sharmistha
yes i got it..
thanks 4 ur reply..
Sharmistha
sharmistha
Hii,
when i create implementation through se18 ,i got the method
method IF_EX_BADI_MATERIAL_CHECK~CHECK_MASS_MARC_DATA.
which is diffrent from ur method method IF_EX_BADI_MATERIAL_CHECK~CHECK_DATA.
and when i write the code inside the method like
method IF_EX_BADI_MATERIAL_CHECK~CHECK_MASS_MARC_DATA.
if WMARA-MATKL eq ‘A05′ and WMARA-SPART eq ‘02′.
message ‘Material creation for this Group should be avoided for animal products!!’ TYPE ‘I’.
endif.
endmethod.
it shows a error Field “WMARA-MATKL” is unknown. It is neither in one of the specified
tables nor defined by a “DATA” statement . . . . . . . . . .
what to do?
plz help
sharmistha
Raj
Hi
its very basic thing.all the bad might not have same importing parameters.
WMARA Is available in my badi .please check the signature of thwarting badi
which you are trying to use.it might not contain WMARA as its importing parameter.
There might be different parameter which contains the data.
Thanks
Raj
SAP IGnite
sharmistha
i just copy paste ur badi which u post ..but it shows the same error..and the badi have a importing parameter wmara,which i check on double clicking on check_data…
also tell me plz why ur method is different from my method like
method di IF_EX_BADI_MATERIAL_CHECK~CHECK_MASS_MARC_DATA.
which is diffrent from ur method method IF_EX_BADI_MATERIAL_CHECK~CHECK_DATA.
i work on ecc 6.0….
thanks .
sharmistha
Harikrishna
Hi Experts,
My requirement is, while creating a service using tcode ML81N, If the reference number already exists means, then one error message has to be displayed.
Is there any BADI or User Exit available for this., please let me know.
Thanks in Advance.
Harikrishna
Tab
Dear raj,
Thanks for the wonderful go thru of BADI implimentation, but I just wonder how and where is the method CHECK_DATA being called when creating a material. I mean there must be a call to the implemented method also during the flow of the transaction.
Raj
Hello Tab,
As i explained the BADI is a hook. Standard SAP creates it and place it in the code.
That code contains call to the appropriate method ( like CHECK_DATA )
so in implementation phase you just need to implement it using Se19 ,
As the code is already placed to make a call it will trigger your implication automatically.
Thanks
~Raj
Harshal
Thanks a ton Raj..
Your posts are really helpful to beginner..
Thanks again for your help.
Rekha
Hi Raj,
I have seen so many articals and explanation in net regarding BAdi, Userexits , but u r amazing yar, realing Happy & thanks a lot for u r effort.
Thaks,
By
Rekha.:-?
mahesh reddy
Eshant
Hi Raj,
I am learning ABAP and quite new. Could you please explain the basic concept of BADI. Everywhere the way of using badi (business Addin) I see on internet is they use Class CL_EXITHANDLER’s GET_INSTANCE method. They find badi and then make some modifications. But I am not clear whats the concept behind this specific class name.
Please put some light on basic flow of steps or an approach to use badi.
Why do we use it? Why can’t we use exits only?
Regards,
Eshant Garg
Rubencio
THX Raj.
Marco
Hi Raj,
thanks for your great Tutorial!
I’ve implemented the BADI “BADI_MATERIAL_CHECK”.
Can you tell me, how I can check if the field “individual and coll. reqmts”, MARC-SBDKZ located on MRP 4 view in Material Master, has changed?
So I don’t have to do my checks every time the material master is saved.
Thanks,
Marco.
Raj
Hi Marco
I guess I have not understood question correctly or you have over looked..as marc is in importing parameters you can validate the field content
And raise exception or error message..
Thanks
Raj
Sap ignite
Marco
Hi Raj,
thanks for your answer.
Yes, I have marc in the importing parameters and I can check the current value of eg. MARC-SBDK. But how can I determine that this field has actually changed? I’m looking for something like
IF old_sbdk NE marc-sbdk.
[Do some checks]
ENDIF.
The only way I know is to do a select on the current value stored in the database and to compare this to my current value in the structure marc.
I hoped that there is a more “elegant” way to do this instead of doing a database read. (so maybe the old values are somethere in the memory or something like this).
Thanks,
Marco.
Marco
It’s me again…
I found the solution myself
I use a dirty assign to get the old marc values:
SPAN { font-family: “Courier New”; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } FIELD-SYMBOLS:
<ls_omarc> TYPE marc.
* Get old MARC values by Dirty Assign
ASSIGN (’(SAPLMGMU)OMARC’) TO <ls_omarc>.
At this point <ls_omarc>-sbdk has the old value assigned and I can check with
SPAN { font-family: “Courier New”; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S52 { color: #0000FF; } .L0S70 { color: #808080; }
IF <ls_omarc>-sbdkz <> wmarc-sbdkz
if the value has really changed.
Thanks,
Marco.
sudha
hello sir.. i am new to abap and have a requirement..using VENDOR_ADD_DATA badi , if you modify the data it should modify in database..so can you please say me the procedure and coding..pls help me out sir
Nikhil H
Hi Raj
I have a requirement,suppose i am entering a value in a field lets take an example,
material group, if i enter material group value as MM_a05 then it should get save in database as a05, and whenever i go to mm03 transaction to display that material,It should give the value of material group as MM_a05.
hope you understood my requirment.
Thanks in Advance.
Nikhil H
Hi Raj
I have a requirement,suppose i am entering a value in a field lets take an example,
material group, if i enter material group value as MM_a05 then it should get save in database as a05, and whenever i go to mm03 transaction to display that material,It should give the value of material group as MM_a05.
hope you understood my requirment.
Thanks in Advance.