Validate Commodity Codes in LSMW Before Loading

Jimbo's picture

Hierarchical mountain goatsThe task of validating data often falls on the shoulders of the Data Conversion team because it is the last step before loading the data. Validating data is hard, time-consuming work so the opportunity to pass the buck may be too great for some resources.

Another great tactic is to wait until the end of the business day to hand off the data to the migration team. This allows for the resource preparing the source data to leave and not be involved in the time-consuming task of validating the data.

So many of the code snippets on this site are simply the children of necessity. Automating the last-minute validation of data before attempting to load into a test system or into production. Source data that has not been validated tends to produce errors like the one below.
Commodity code error message.

In this example the Commodity Code does not exist. This error (and many others) can be avoided with a simple snippet of code that compares the source data against the configuration or dependencies in the system.

This snippet requires no variables to be defined. It can be added at the field definition and works without any additional effort. It writes out a line as part of a meaningful validation report that is immeasurably better than "Well, some failed."

translate IMMH1-HERKL to UPPER CASE.
select single STAWN into BMMH1-STAWN from T604
if sy-subrc ne 0.
  write: / BMM00-MATNR, BMM00-WERKS,
         'Invalid Comm.Code (STAWN):',  IMMH1-STAWN color 6.
Programming Language: