Mar 23, 2016

User-exit to verify Valuation Class in MM02

Requirement:
To put a verification/validation when Valuation Class in MM02 is modified/changed.
Check if the new Valuation Class is listed in table T023 for the same Material Group (MARA-MATKL). If not, issue error message.

Solution:
Using EXIT_SAPLMGMU_001. There is changing parameter structure CMARA in this FM which contains VOLUM field. you can change volume by changing this field. The project name is MGA00001 in SMOD transaction.

1. Transaction CMOD. Project name MGA00001


2. Choose Enhancement MGA00001. and click Components

3. Double click on EXIT_SAPLMGMU_001

4. Double click on Include ZXMG0U02

5. Write the Codes, saved and activate.


  DATA lv_t023_bklas TYPE t023-bklas.

  SELECT SINGLE bklas FROM t023 INTO lv_t023_bklas
    WHERE matkl = wmara-matkl.

  IF sy-subrc EQ 0.
    IF wmbew-bklas NE lv_t023_bklas.
      MESSAGE w398(00) WITH 'Invalid valuation class' wmbew-bklas space.
      RAISE APPLICATION_ERROR.
    ENDIF.
  ENDIF.


6. Activate the User-exit.


Testing & result:

1. MM02 for Material. Material 4000000285 with Material Grup 0510150

As known in Table T023, Valuation Class allowed is GP05

2. Valuation Class changed to GP01

3. When saving, error message occurs.



No comments :