Você está na página 1de 6

Example3 on BADI

BUSINESS REQUIREMENT For all the materials in our company, Please add a prefix REL- for the description of a material in transaction MM01/MM02.

STEP 1:Find the list of the BADIS for TCODE XKO2.

GO TO SE24

Give the class name as CL_EXIT HANDLER

Click on display

Double click on the method GET_INSTANCE

Put a break point

Execute the TCODE MMO2

Give the material no as 23 Press enter

The debugger will start Dont note down any BADI NAMES as we are not interested for the first screen. Select all the check boxes and press enter Again The debugger will start Dont note down any BADI NAMES as we are not interested for the second screen also. Change the material description and save it. The debugger will start

Now, note down list of BADI NAMES as we are interested for this material description screen.

BADI names are : BADI_GTIN_VARIANT BADI_MATERIAL_CHECK EHSS_SPEC_CHECKS

Go to se18 Give the BADI NAME And check all the methods Find the suitable/roughly decide BADI name and method by reading the description and checking the signature. Example : Run the transaction SE18 to see the details of BADI.

Click on display button to see the methods declared in that.

Choose the method where the material description is defined.

Then create implementation

Step 2 : Creating implementation for the BADI

Go to SE19

give u r standard BADI name : BADI_MATERIAL_CHECK. Give the implementation name as Z BADI_MATERIAL_CHK

Click on create Give the description

Double click on the method CHECK_DATA

Put a static or dynamic break point inside the method and activate the class method Click on back Activate the implementation

Step 3 : TESTING weather BADI is correct or not Now run the transaction MM02 and change the description of material Our BADI will be triggered with a break point So, this is the BADI and method which we can use for this business requirement. Finally write the below code

SAVE AND ACTIVATE THE METHOD. Click on back Activate the implementation

Step 4: UNIT TESTING

Now test the transaction MMO2 Give material no as 23 and press enter Select all checkboxes. Change the description as screw material Click on save. The material desc will be saved as REL- screw material Now Run the transaction MMO3 Give material no as 23 and press enter Select all checkboxes. Check the description. It will be REL- screw material

Contains String(cs):
This statement is used to check if the content/characters of operand2 is contained in operand1.

concatenate:
This statement is used to concatenate two or more strings into a final string.

Você também pode gostar