Filter out the base Unit of Measure when loading material views.
The RMDATIND
program is a great tool for loading Material Master data, but in some screens it rejects any Unit of Measure that is the same as the base Unit of Measure for said Material Master. Replacing that Unit of Measure with a blank value resolves this easily and can be done with this short snippet of code.
We start with an easy way to ensure that the material can be found in the MARA table by padding numeric values with zeros. It is assumed that the materials have been pre-validated and already exist in the MARA table. Additionally, the Unit of Measure is translated to upper case; values in the MSEH3 field of T006A are always upper case.
The MARA table is joined with the T006A table and the results are compared against the Unit of Measure in the source data. If it matches then the target field is populated with a blank value. If the values do not match then the target field is populated with the source data. This snippet requires no declaration of variables or tables.
if IMMH1-MATNR co '1234567890 '. shift IMMH1-MATNR right deleting trailing space. overlay IMMH1-MATNR with '000000000000000000'. endif. translate IMMH1-SCHME to UPPER CASE. select single MEINS into BMMH1-SCHME from MARA join T006A on ( MARA~MEINS eq T006A~MSEHI ) where MATNR eq IMMH1-MATNR and T006A~SPRAS eq 'E' and T006A~MSEH3 eq IMMH1-SCHME. if sy-subrc eq 0. "Base unit of measure! Leave blank! BMMH1-SCHME = ''. else. BMMH1-SCHME = IMMH1-SCHME. endif.