I have tried to match CS12 to the output from the function CS_BOM_EXPL_MAT_V2 , but have had no success.
So I have created some SQL that would build the BOM. It displays too many components compared to the list of components displayed in the CS12 function. So far I am using MAST and STPO to build a product structure, is this correct?
Does the CS12 function select only a subset of the BOM, what is the criteria?
Is there another table or set of criteria I need to slim down my component list?
I haven't found anywhere in the tables where the unit is carried, do you know how to determine the unit?
Where is the effectivity carried in the BOM tables?
Here's the logic I have put together:
Obtain top level material:
select m.MATNR,
m.STLNR,
s.STLKN,
s.AENNR,
s.POSNR,
s.OBJTY,
s.IDNRK,
m.werks
from MAST M,
STPO S
where m.mandt = '555'
and m.matnr = vMATNR <== top level material
and m.werks = vWERKS <== specify the plant
and m.stlan in (1,3)
and s.stlnr = m.stlnr
ORDER BY POSNR;
Obtain component
select m.MATNR,
m.STLNR,
s.STLKN,
s.AENNR,
s.POSNR,
s.OBJTY,
s.IDNRK,
m.werks,
from MAST M,
STPO S
where m.mandt = '555'
and m.matnr = vIDNRK <== use the idnrk from the previous row
and m.werks = vWERKS <== specify the plant
and m.stlan in (1,3)
and s.stlnr = m.stlnr
ORDER BY POSNR;
Then I perform a check and throw out the component if it is not applicable to the model specified. I use the AENNR to determine if this bom component is part of the specific model of interest
So either the row has to exist in AEEF for the model specified or there has to be an existing row with the matnr_lo = NULL - I think this may mean it is applicable for all models?!
SELECT count(*)
into vMODEL_EXISTS
FROM AEEF
WHERE AENNR = vPSrow.AENNR
and MATNR_LO = vMODEL <== specify model number;
SELECT count(*)
into vNULL_MODEL_EXISTS
FROM AEEF
WHERE AENNR = vPSrow.AENNR
and MATNR_LO is null;