I'm trying to programmatically determine the batch class name for a given material. I thought the table to use was KSSK. When I query that table with a material number and class type 023, I get an internal class number. From there I query KLAH with the internal class number expecting to see the class name that is showing on the classification view of the material master, but instead I see a different class name.
Does anyone know what I am doing wrong?
Thanks in advance for any help you can provide.
Were you ever able to find out which table stores a Materials batch class assignment?
I've been querying KSSK with which many articles seem to point to using OBJEK = MATNR (material #) and the only results I get are the materials 'Material Class' assignment. No entries whatsoever for KLART (Class Type) 023.
I'm not sure where I can find this, but the Batch Class assignment (023) entry clearly displays on the Material Masters Classification View (MM03-Classification).
The table that I believe that you are looking for is INOB.
Within INOB, specify 023 for field KLART and MARA for field OBTAB. The field OBJEK with contain your material number.
The field CUOBJ will contain a key that can link back to table KSSK to field OBJEK.
From there, table KSSK contains the link to KLAH to get your class name.
I hope this helps.
Hi - this is a reply to quite an old post, but I figured out a slightly more elegant way to get what you want, using function modules rather than table lookups (puts the onus slightly more on SAP). Any hoo - here's what I did:
Use FM CLAF_CLASSIFICATION_OF_OBJECTS but I set the arguments in a slightly odd way... and it worked.
CLASSTYPE = "022" (or "023" in your case)
OBJECT = <18-digit Material Number and that is all - nothing else appended or concatenated>
OBJECTABLE = "MARA"
The FM returns a list of the classes in T_CLASS, and a list of characteristics for those classes in T_OBJECTDATA. The "tabix" field of a given row in T_OBJECTDATA relates to the class row in T_CLASS.
In this case, I suppose because the the ClassType = 022, it is returning the Batch Class to use for the Material.
Soooo... you can either loop through T_CLASS and find your class name, or if you know a characteristic of the class you could find the characteristic in T_OBJECTDATA and work backwards through "tabix" to get the row in T_CLASS.
If you set
CLASSTYPE = "022"
OBJECT = <Concatenation of 18-digit Material Number, Plant, Batch Number, etc.>
OBJECTTABLE = "MCHA"
It would return the same data for you... AS LONG AS the Batch has already been classified! But what if the batch has not yet been classified? In that case, this second approach fails with a hard exception that the object is not yet classified.
If, on the other hand, you set
CLASSTYPE = "001"
OBJECT = <18-digit Material Number>
OBJECTTABLE = "MARA"
Then it returns the classes for the Material itself.
Hope that helps someone.