Determine What Classification Materials Are Assigned To
When assigning classifications to materials it helps to check to see if the material is already assigned to a classification. In some cases materials can have just one type of classification assigned to it. For example, materials cannot have multiple batch classifications assigned to them.
Recent attempts to coax transaction CL20 to remove classifications from a material have proved fruitless; a recording that calls CL20, or CL20N will work to remove classifications from materials that are not in a BOM or used in some other way that SAP deems disruptive to the classification removal process. Recordings based on the MM02 transaction can also be used to remove classifications from materials.
Material classifications and batch classifications are stored in the same way in the system, but are linked slightly differently to the material to which they are assigned. Materials stored in MARA are linked to material classifications through KSSK by the OBJEK field and then to the KLAH table by the CLINT field. Materials connect through INOB table to KSSK and then to KLAH.
- Material classifications
- MARA-MATNR → KSSK-OBJEK
- KSSK-CLINT → KLAH-CLINT
- KLAH-CLASS
- Batch classifications
- MARA-MATNR → INOB-OBJEK
- INOB-CUOBJ → KSSK-OBJEK
- KSSK-CLINT → KLAH-CLINT
- KLAH-CLASS
Adding counters to keep track of the classifications that are already loaded and those that have conflicting classifications is a great way to provide feedback to the parties responsible for maintaining the data. This feedback makes refining the source data much easier. Add this code to the Global Data Definitions area.
parameters: p_verbos as checkbox. data: lMARA like MARA, lCABN like CABN, lKSSK like KSSK, lKLAH like KLAH, lINOB like INOB, lKSML like KSML. data: nAlreadyIn type i, nConflict type i, nIndex type i, cOBJEK.
Increment the counter at the start of processing for each record by adding it to the BEGIN_OF_TRANSACTION
area.
add 1 to nIndex.
Add this to the OBJEK field to determine if the tool should try to add the classification or not.
SELECT SINGLE * FROM MARA INTO LMARA WHERE MATNR EQ CLASS_S-OBJEK. if sy-subrc ne 0. WRITE: / nIndex, CLASS_S-OBJEK COLOR COL_NEGATIVE, CLASS_S-CLASS, 'Material not created in system.'. skip_transaction. else. move lMARA-MATNR to BIKSSK-OBJEK. move lMARA-MATNR to cOBJEK. "Check for batch classifications. select * from INOB into lINOB where objek eq lMARA-MATNR and KLART eq CLASS_S-KLART. move lINOB-CUOBJ to cOBJEK. "We're looking for batch classification. endselect. select * from KSSK into lKSSK where OBJEK eq cOBJEK and KLART eq CLASS_S-KLART. select * from KLAH into lKLAH where CLINT eq lKSSK-CLINT. IF lKLAH-CLASS EQ CLASS_S-CLASS. if p_Verbos eq 'X'. WRITE: / nIndex, CLASS_S-OBJEK COLOR COL_POSITIVE, CLASS_S-CLASS, 'already has classification', CLASS_S-CLASS, 'skipping!'. endif. add 1 to nAlreadyIn. cFail = 'X'. else. write: / nIndex, CLASS_S-OBJEK color col_negative, CLASS_S-CLASS, 'already has a classification.', lKLAH-KLART, lKLAH-CLASS. add 1 to nConflict. cFail = 'X'. "skip_transaction. endif. endselect. endselect. endif.