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 if no join exists. 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.

https://cranfieldcbp.files.wordpress.com/2017/06/ankerblog1.png?w=584|https://i.pinimg.com/originals/d7/27/f7/d727f717634989af227505c538daf56c.jpg|https://www.poweradmin.com/blog/wp-content/uploads/2015/10/dilbert-network-monitoring-c120904.png|https://www.cs.vu.nl/~frankh/dilbert/basic-research.gif|https://blog.capterra.com/wp-content/uploads/2015/12/dt051228-720x228.gif|https://i.pinimg.com/originals/7d/b5/30/7db53009ee5c713ba87157df46a53311.png|https://www.markhowelllive.com/wp-content/uploads/2011/11/dimension-where-fantasy-and-reality-trade-places1.gif|https://external-preview.redd.it/uLb-67VKLgD5VPuOgk2eY6xcHpDrEx-aYzFlrLZq-2c.jpg?auto=webp&s=77f1c806adcfa35f08f327b197a664824cdb8167|https://9.9.9.9

Programming Language: 
ABAP