At the time of material creation we often activate Batch
Management. It means different materials will have different batches. Hence,
material & batch both will behave as a unique. At this point the Valuation
Category needs to be activated. If we don’t activate Valuation Category then
there will be no meaning to activate batch management. Because Valuation
Category always ensures that the different batch will hold different price of
the materials. If it is not activated in this case, then all materials need to
satisfy average price of the batch. At this point the valuation will be wrong
for those materials.
In the following BADI we have created a simple logic by
which Valuation Category will be mandatory if Batch Management is activated at
the time of creating a material; t-code MM01. The required BADI is
BADI_MATERIAL_CHECK. Now we implement this step by step.
1. Go to SE18 & enter BADI name and display.
2. We need to add our custom code inside the CHECK DATA.
3. Go to SE19 & enter the BADI name and create Implementation.
4. Enter implementation name and then go to Interface.
5. Double click on CHECK DATA method.
6. It will open with the editor. Write the required code here. Then save -> check -> active.
7. Go back and click on the Active button. By this the BADI is activated.
METHOD if_ex_badi_material_check~check_data.
IF wmarc-xchar = 'X'
AND ( wmara-mtart = 'ROH' OR wmara-mtart = 'VERP' )
AND sy-tcode = 'MM01'.
IF wmbew-bwtty IS INITIAL.
MESSAGE 'Valuation Category is mandatory (Value = X)'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
ENDIF.
ENDMETHOD.
IF wmarc-xchar = 'X'
AND ( wmara-mtart = 'ROH' OR wmara-mtart = 'VERP' )
AND sy-tcode = 'MM01'.
IF wmbew-bwtty IS INITIAL.
MESSAGE 'Valuation Category is mandatory (Value = X)'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
ENDIF.
ENDMETHOD.
1. Now go to MM01.
2. Select the required views and enter.
3. Enter plant & s-loc, and then enter.
4. Check the Batch Management.
5. Create the Inspection Setup.
6. Now keep Valuation Category blank and then try to save the material.
7. It will give the Information (display like error) message.
8. Now enter the Valuation Category and the save the material.
9. The material has been created and we can check the Valuation Category details in the MARC table.
55 comments:
Post a Comment