Add an index to reports generated in LSMW

Jimbo's picture

The Convert Data step in LSMW is a great place to validate data with bits of ABAP and to produce a report that enables those responsible for cleansing to easily find problems with the source data. Catching errors at this point and excluding erroneous records from the load is always preferable to letting bad data pass through the conversion process and then allowing it to fail during the load only to then use the error log as a reporting tool.

Load logs often contain ambiguous or incomplete data. Log entries from batches created with recordings include messages like "Field EINE-BPUMZ. is not an input field", "Formatting error in the field EINA-MEINS; see next message" or "Fill in all required entry fields". These messages contain no information that can explain to the cleanser what went wrong with the transaction.

An index provides an easy way to create a one-to-one relationship between error messages and records in a source file. When viewed in Excel, the error messages can be viewed right next to the source record and that saves the cleanser time, energy and stress. Properly cleansed data is a key component to a successful implementation.

Add this line of code to the Global Definitions section. It declares an integer variable called nIndex.

data: nIndex type i. 

Add an statement to increment the index at the beginning of each record. A fine place to put it is right after the XKEEP variable in the Batch Input Structure for Session Data block, but anywhere at the beginning of the transaction data code will do.

BGR00-XKEEP = 'X'. add 1 to nIndex.

Add the nIndex to the beginning of each line written to the report.

  write: / nIndex, CLASS_S-OBJEK color col_negative,
   CLASS_S-CLASS,
  'already has a batch classification. Multiple not allowed.'.

Now, convert the data and look at the results. Some minor tweaking may be needed to enrich the data with as much information as is needed for the cleansers. Summing up all of the errors that are found within the data is a great way to provide metrics for the project management office.

Programming Language: 
ABAP