Skip to Content
Author's profile photo Tanmay Verma

Mandatory Views in Material Master – MM01 and MM02

How to make material master views mandatory ?’. This is one of the often asked questions on SCN. I also came across a similar requirement and after going through several posts in got an idea on how to achieve this. However , the steps to achieve the requirement were not properly documented and were spread across multiple posts which prompted me to write this blog post.


  • Make Basic Data 1 , Basic Data 2 and Classification Data Views as mandatory. An error message should be triggered if the user tries to save a material without maintaining these views.
  • Make all material classes and material characteristics mandatory.
  • This should work for both MM01 and MM02. Thus a user should get an error is a new material  is being created without mandatory views through MM01 or changes are being done to an existing material not having the mandatory views.


  • We will make use of  customer-exit EXIT_SAPLMGMU_001 to write our logic.

  • Function module MAIN_PARAMETER_GET will be used to get the views currently being maintained or views already present for a material ( material extension or change scenario).

  • CLAP_DDB_ALLOCATION_FR_BUFFER will be used to read the material classes in buffer.

  • CLAP_DDB_GET_BUFFER_PARAMS to read the material characteristic values in buffer.

  • CLAF_CLASSIFICATION_OF_OBJECTS to get the material characteristics from database.
  • Further explanations are given below as a part of comments in code snippets for better understanding.

Check for mandatory views:

Function module MAIN_PARAMETER_GET will give the list of material master tables that are going to be updated. The tables parameter MTAB is filled with the list of used tables at run time.

This table has 2 fields which we need to read to get the views being maintained.

MTAB-BISTSTAT will have the list of views that already exist for a material.

MTAB-PFSTATUS will have the list of views currently being maintained.




        mtab = lt_mtab.

    IF sy-subrc EQ 0.

*–Check the existing view and current views being created.Read for table MARA. The status for  Basic Data is ‘K’ and classification data is ‘C’.

      CLEAR ls_mtab.

      READ TABLE lt_mtab INTO ls_mtab WITH KEY tbnam = ‘MARA’

      IF sy-subrc EQ 0.

*–Check for basic view

        IF ls_mtab-biststat CA ‘K’ OR ls_mtab-pfstatus CA ‘K’.

*–Basic Data View is present ( Do nothing )


*–Give error message

         MESSAGE ‘Material Master Views Basic Data 1 / Basic Data 2 are mandatory’ Type ‘E’.


*–Check for classification view

        IF ls_mtab-biststat CA ‘C’ OR ls_mtab-pfstatus CA ‘C’.

*–Classification Data View is present ( Do nothing )


          MESSAGE ‘Material Master View Classification is mandatory’ type ‘E’.




Check for mandatory classes and characteristic values in Classification View:

If user is currently maintaining classification view ( MM01 material create ) then the check should be done from the buffer values else in case of material extension or change ( MM02 ) the values should be read from database to check for completeness.


Check buffer values ( material create – MM01 ).

*–If classification data tab is currently being maintained

IF ls_mtab-pfstatus CA lc_c.

*–Check for material classes

      CLEAR lv_objkey.

*–Pass material number in object key

       lv_objkey = cmara-matnr.

*–Read buffer values

      object                       = lv_objkey
      classtype                  = ‘001’
      ptable                       = ‘MARA’
      t_allocations            =  lt_allocations
      no_allocations_in_buffer = 1
      class_not_in_buffer        = 2
      allocation_not_in_buffer = 3
      missing_parameter        = 4
      others                           = 5.

*–Delete the values in lt_allocations where VBKZ is ‘D’ (deleted allocation )
*–So after delete we will only have unchanged values ( VBKZ ‘ ‘) or
*–newly added ( VBKZ ‘U’ ).This ensures that we take care of allocations
*–being deleted in current maintenance

DELETE lt_allocations WHERE vbkz EQ ‘D’. 

*–Now we can check in table lt_allocations whether all classes are present or not

*–Loop at the table and check if all the  required material classes  are present.

*–If required classes are not maintained give error message else proceed.

*–Check for mandatory classifications

= lv_objkey
= ‘001’
= ‘MARA’
= lt_ausp.

*–Delete the values in lt_ausp where STATU is ‘L’ ( old values )
*–So after delete we will only have unchanged values ( STATU ‘ ‘) or
*–new changed values ( STATU ‘H’ ).This ensures there is only 1 entry
*–per classification

DELETE lt_ausp WHERE statu EQ ‘L’

*–Now we can check in table lt_ausp whether values for all material classifications are present

*–or not. If not the trigger error message.


Check data base values ( MM01 – material extension scenario where classification tab is not maintained currently OR MM02 – material change ).

*–If classification tab is not being maintained currently


*–Pass material as object key

lv_objkey = cmara-matnr.

      classtype          = ‘001’
      object               = lv_objkey
      t_class             = lt_class
      t_objectdata      = lt_objectdata
      no_classification    = 1
      no_classtypes        = 2
      invalid_class_type  = 3
      OTHERS              = 4.

*–Check for mandatory classes

*–Check in table LT_CLASS if all the material classes are present. If not then trigger an error message.

*–Check for characteristic values

*–Fetch the characteristic details from CABN

*–Check if values exist for each characteristic in table LT_OBJECTDATA.

*–To determine if a value for characteristic has been given compare with character ‘?’

*–If values are not present  CLAF_CLASSIFICATION_OF_OBJECTS returns ‘?’ else it can be blank or some value.


Execution Snapshots:

Go to MM01 to create material:


Enter material number , industry sector and material type. Select views to be maintained. Do not select Basic Data views.


Enter data on views selected:



Save the material.


Error message is triggered.


  • The class type for material class is ‘001’.
  • Material classes and characteristics related data can be fetched from tables KLAH ,KSML, AUSP and INOB.
  • Characteristic details can also be fetched from table CABN and CAWN.
  • The buffer related function modules and FM MAIN_PARAMETER_GET will only work when material is created through transactions and not when created through BAPIs.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Philippe Campels
      Philippe Campels

      Badi BADI_MATERIAL_CHECK can also be used to make these kinds of checks.

      That's what we have done to have the classification view mandatory for any new material creation.

      Author's profile photo Tanmay Verma
      Tanmay Verma
      Blog Post Author

      Hi Philippe ,

      Thanks for the info. I think i had checked this BADI but was not able to use it as per my requirements. It would be great if you can share how you used it.



      Author's profile photo Sergiu Ionescu
      Sergiu Ionescu

      Hi Tanmay,

      Please can you post the declaration part of your code (DATA: and TABLES:) please.

      Much appreciated,


      Author's profile photo Tanmay Verma
      Tanmay Verma
      Blog Post Author

      Hi Sergiu,




      lt_mtab        TYPE STANDARD TABLE OF sptap,

      lt_class       TYPE STANDARD TABLE OF sclass,

      lt_objectdata  TYPE STANDARD TABLE OF clobjdat,

      lt_allocations TYPE STANDARD TABLE OF rmclkssk,

      lt_ausp        TYPE STANDARD TABLE OF rmclausp.

      *--Work areas

      ls_mtab        TYPE sptap,

      ls_objectdata  TYPE clobjdat,

      lv_objkey      TYPE objnum.


      Author's profile photo Sergiu Ionescu
      Sergiu Ionescu

      Thank you.

      Author's profile photo DSB INFORMATIK

      Thanks for sharing.

      But when I try to syntax check, it says: FIELD LC_C is unknown.

      Can you please share the data declaration OR explain where this should be specified?



      Author's profile photo Tanmay Verma
      Tanmay Verma
      Blog Post Author

      Hi Karsten,

      LC_C should be 'C'. You can declare this constant at the top.



      Author's profile photo Erik Vaneylen
      Erik Vaneylen

      Hello Tanmay,


      Thanks for sharing this interesting post.

      Do you know what the exact differences are between the different types of statusses? (BISTSTAT vs BISSTATU vs PFSTATUS)? Data type SPTAB tells me they’re all maintenance statusses, so I wonder what the difference is.

      I’m actually looking for an easy way to see which status/view was updated. (like what is stored in table MSTA, but then before it’s stored there)

      Looks like the statusses above are also populate if the view was created before, but not necessarily updated during this MM02 session. (also looked at WSTAT in WMARA in UE MGA00001 – didn’t help so far)

      Thanks in advance,


      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal

      Hi Tanmay Verma ,

      I noticed something that be beneficial for abapers. When you maintain a characteristic value, it might be empty altough you want to do mantory field. SAP updates  lt_allocations-statu = '5' !!!


      I designed a logic like a ' if i have statu = '1' , i can go on next step !!!


      M.Ozgur Unal

      Author's profile photo Tanmay Verma
      Tanmay Verma
      Blog Post Author

      Thanks Mehmet.