10-14-2008 4:18 PM
Hi, I'm using function CS_BOM_EXPL_MAT_V2 to get material BOMs but i've found a problem..
There is an order that I get its BOM using tx. CO03 and there I can see 19 components. then I run function CS_BOM_EXPL_MAT_V2 with that material and there is only 13 components..
Is there any other funciton to get the BOM exlosion ??
thanks in advance...
Maria
10-14-2008 6:24 PM
remember, also, that in CO03, if there are phantom items in the first level of the BOM, CO03 will show the components of the phantom, which MAY be where the extra items are coming from. In such a case, you could check for a phantoms and explode them into thier components. the FM you are using i think is fine. you need to adjust how you are using it to support the difference in what you are seeing as output, in my opinion.
10-14-2008 4:24 PM
Hi Maria,
Try this Function Module
CS_BOM_EXPLOSION_MAT
Regards
Bala Krishna
10-14-2008 4:30 PM
Hi Maria,
You can try this FM: CSAP_MAT_BOM_READ.
It worked well with me.
Happy coding
//Kiran
10-14-2008 4:41 PM
10-14-2008 6:24 PM
remember, also, that in CO03, if there are phantom items in the first level of the BOM, CO03 will show the components of the phantom, which MAY be where the extra items are coming from. In such a case, you could check for a phantoms and explode them into thier components. the FM you are using i think is fine. you need to adjust how you are using it to support the difference in what you are seeing as output, in my opinion.
10-15-2008 7:45 AM
hi, thanks for all the answers.. the way I use the module function is the following:
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
aufsw = ' '
capid = ' '
datuv = sy-datum
ehndl = '1'
mmory = '1'
mtnrv = _matnr
stlal = _stlal
stlan = _stlan
stpst = 0
werks = _werks
TABLES
stb = stb
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
How can I get phantom components ??? And how can I see if a material is a phantom material ??
Thanks in advance !!
Maria
10-15-2008 12:38 PM
look at stb-sobsl... this is the special procurement type, which defines an item as a phantom.
once you know an item is a phantom, you can explode it again to get its components. hopefully, you dont nest phantoms within phantoms.
10-15-2008 1:00 PM
thanks.. but i've realized that some of the missing components are not phantom items....
10-15-2008 1:06 PM
the missing items would be COMPONENTS of a phantom, not the actual phantom.
run CS12, and enter the ordered material from the production order. add the phantom indicator (it is just called "Phantom Item") to the ALV. i think you will find your missing items as a second level components of one of the materials that has a phantom indicator on it.
10-15-2008 1:12 PM
Hi, Maria, CS_BOM_EXPL_MAT_V2 is used to explode BOM, the result is the same as transaction code CS03 if you explode one level BOM. Or you can used CS12 to check multiple levels BOM.
CO03 display all components of the production order, production order explode bom to the first non-phantom item, and you can delete, change, insert components with CO02.
So maybe there are difference between them.
10-15-2008 1:16 PM
In CO03 there are 19 components, when I run CS_BOM_EXPL_MAT_V2 I get only 13, when running CS12 I get lots of components in several levels but there is one that doesn't appear..
I've tried creting a report whose code is the following:
REPORT zlista_mat.
DATA: lv_stlnr LIKE mast-stlnr,
lv_tabix LIKE sy-tabix,
lv_rgekz LIKE marc-rgekz,
lv_stlal LIKE mkal-stlal,
lv_stlan LIKE mkal-stlan.
DATA: lv_sobsl LIKE marc-sobsl,
lv_fvidk LIKE marc-fvidk.
lv_stlal LIKE mkal-stlal,
lv_stlan LIKE mkal-stlan.
*
DATA: BEGIN OF it_stpo OCCURS 0,
idnrk LIKE stpo-idnrk,
menge LIKE stpo-menge.
DATA: END OF it_stpo.
DATA: BEGIN OF it_stpo_aux OCCURS 0.
INCLUDE STRUCTURE it_stpo.
DATA: END OF it_stpo_aux.
DATA: BEGIN OF it_stpo_hijos OCCURS 0.
INCLUDE STRUCTURE it_stpo.
DATA: END OF it_stpo_hijos.
SELECT SINGLE stlal stlan
INTO (lv_stlal, lv_stlan)
FROM mkal
WHERE matnr = '000000000000301140'
AND werks = '11'.
AND verid = pe_version.
IF sy-subrc = 0.
CLEAR: lv_stlnr,
it_stpo.
REFRESH it_stpo.
SELECT stlnr
INTO lv_stlnr
FROM mast UP TO 1 ROWS
WHERE matnr = '000000000000301140'
AND werks = '11'
AND stlan = lv_stlan
AND stlal = lv_stlal.
ENDSELECT.
IF sy-subrc = 0.
SELECT bidnrk bmenge
INTO TABLE it_stpo
FROM stas AS a INNER JOIN stpo AS b
ON astlty = bstlty AND
astlnr = bstlnr AND
astlkn = bstlkn
WHERE a~stlty = 'M'
AND a~stlnr = lv_stlnr
AND a~stlal = lv_stlal
AND b~datuv <= sy-datum
AND b~sanfe = 'X'.
ENDIF.
ENDIF.
CLEAR it_stpo_aux.
REFRESH it_stpo_aux.
it_stpo_aux[] = it_stpo[].
WHILE NOT it_stpo_aux[] IS INITIAL.
READ TABLE it_stpo_aux INDEX 1.
CLEAR: lv_sobsl, lv_fvidk.
SELECT SINGLE sobsl fvidk
INTO (lv_sobsl, lv_fvidk)
FROM marc
WHERE matnr = it_stpo_aux-idnrk
AND werks = '11'.
IF lv_sobsl EQ '50'.
SELECT SINGLE stlal stlan
INTO (lv_stlal, lv_stlan)
FROM mkal
WHERE matnr = it_stpo_aux-idnrk
AND werks = '11'
AND verid = lv_fvidk.
IF sy-subrc = 0.
CLEAR: lv_stlnr,
it_stpo.
SELECT stlnr
INTO lv_stlnr
FROM mast UP TO 1 ROWS
WHERE matnr = it_stpo_aux-idnrk
AND werks = '11'
AND stlan = lv_stlan
AND stlal = lv_stlal.
ENDSELECT.
IF sy-subrc = 0.
CLEAR it_stpo_hijos.
REFRESH it_stpo_hijos.
SELECT bidnrk bmenge
APPENDING TABLE it_stpo_hijos
FROM stas AS a INNER JOIN stpo AS b
ON astlty = bstlty AND
astlnr = bstlnr AND
astlkn = bstlkn
WHERE a~stlty = 'M'
AND a~stlnr = lv_stlnr
AND a~stlal = lv_stlal
AND b~sanfe = 'X'.
APPEND LINES OF it_stpo_hijos TO it_stpo_aux.
APPEND LINES OF it_stpo_hijos TO it_stpo.
ENDIF.
ELSE.
ps_componente = it_stpo_aux-idnrk.
EXIT.
ENDIF.
ENDIF.
DELETE it_stpo_aux INDEX 1.
ENDWHILE.
And I still miss one component !!!!!! And this component is not a phantom item..
10-15-2008 1:58 PM
hi maria ,
If the BOm is sales ordr BOm then use the function module 'CS_BOM_EXPL_KND_V1'
and pass the following parameters ,
call function 'CS_BOM_EXPL_KND_V1'
exporting
capid = capid
cuobj = cuobj
datuv = '99991206'
emeng = kwmeng
mehrs = 'X'
mtnrv = matnr
werks = werks
vbeln = vbeln
vbpos = posnr
tables
stb = p_stpox
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
others = 9.
if sy-subrc <> 0.
message s100 with 'Sales Bom Explosion Error - ' vbeln posnr.
delete idata.
exit.
10-15-2008 2:23 PM