Find Finished Goods without Batch Classification

Jimbo's picture

A recent requirement called for a report that listed all finished goods (material type: FERT) without a batch classification assignment. Normally this would be a five-minute task in SQ00 to create a query, but linking the MARA table to the INOB table in a meaningful way is forbidden by SAP. By adding a few lines of code it is possible to produce the same report using LSMW.

In a previous white paper the topic was determination of class assignment where the tables and joins behind the batch classification system are discussed. Those joins are not supported by SAP's query tool, but this snippet does.

Add the following lines to the GLOBAL_DATA section. This defines the variables that we will be using.

PARAMETERS: p_R_FERT as CHECKBOX default ' '.
data: lMARA like MARA, lMAKT like MAKT,
      lKSSK like KSSK, lINOB like INOB, cFAIL(1) type c.

In the BEGIN_OF_PROCESSING section add this code to produce the report. This report takes several seconds, or even minutes, on a slow system or a system with a great deal of materials. It is only run when the p_R_FERT checkbox is checked.

if p_R_FERT eq 'X'.
  "This report lists all FERT materials without batch assignment.
  select * from MARA into lMARA where MTART eq 'FERT'.
    cFail = 'X'.
    select * from INOB into lINOB
     where objek eq lMARA-MATNR and KLART eq '023'.  "Classification
      select * from KSSK into lKSSK
       where OBJEK eq lINOB-CUOBJ.
        cFail = ''.
      endselect.
    endselect.
    if cFail eq 'X'.
      write: / lMARA-MATNR, lMARA-MTART, lMARA-XCHPF.
      select * from MAKT into lMAKT where MATNR eq lMARA-MATNR.
        write lMAKT-MAKTX.
      endselect.
    endif.
  endselect.
endif.

This report is really easy to tweak based on requirements. Changing the batch type or material is a very simple process and that makes this snippet very versatile.

Programming Language: 
ABAP