Thursday, February 28, 2019

BADI For Material check In SAP ABAP.

BADI FOR MATERIAL CHECK

The Requirement for information message .When you creating a material if material group is A10 and division is: 05.
(This is only use for: As it needs two information for the material and user wants information message while saving the material. we can’t use field exit for this).
First step:
How to find appropriate BADI for this requirement??
Go to T-Code:--SE24
PUT:-- CL_EXITHANDLER.
NEXT:-Click display button.
Add the break- point into Class CL_EXITHANDLER’s GET_INSTANCE method.
Next:-Go to T-code MM01, After that you create a material and try to save it. it stops at many locations with different values of EXIT_NAME. (After checking into Se18 we got the BADI_MATERIAL_CHECK which can be used 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:
Put the name of implementation 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 division which exist in WMARA. Put the below code inside the method then activate the class and method.

IF WMARA-MATKL EQ
‘A10’
AND WMARA-SPART EQ
’05’.
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:
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.


No comments:

Post a Comment