2006 Jul 11 2:54 PM
Hi Experts,
Is there a function that returns the parent
material of the component, not the immediate ancestor
but the PARENT (root) level of the BOM.
Thanks for your help.
Best regards,
Rose
2006 Jul 11 2:57 PM
2006 Jul 11 2:57 PM
2006 Jul 11 3:19 PM
This sample program may be of some help. I fear that this may run a very long time depending on your BOM structure, if it is very complex and deep, then this will take a while, but if it is small like 1 for 1 for 1, then it should work fine.
report zrich_0001 .
data: begin of iitems occurs 0,
matnr type marc-matnr,
werks type marc-werks,
end of iitems.
data: i_stpov type table of stpov with header line.
parameters: p_matnr type marc-matnr,
p_werks type marc-werks.
start-of-selection.
iitems-matnr = p_matnr.
iitems-werks = p_werks.
append iitems.
loop at iitems.
perform where_used tables i_stpov
using iitems-matnr
iitems-werks.
if not i_stpov[] is initial.
loop at i_stpov.
iitems-matnr = i_stpov-matnr.
iitems-werks = i_stpov-werks.
append iitems.
endloop.
delete iitems.
else.
continue.
endif.
endloop.
loop at iitems.
write:/ iitems-matnr, iitems-werks.
endloop.
************************************************************************
* FORM WHERE_USED.
************************************************************************
form where_used tables itab
using matnr
werks.
data: selpool like mc29s.
data: eqpcat like cscequi occurs 0.
data: kndcat like cscknd occurs 0.
data: matcat like cscmat occurs 0.
data: prjcat like cscprj occurs 0.
data: stdcat like cscstd occurs 0.
data: tplcat like csctpl occurs 0.
clear itab. refresh itab.
call function 'CS_WHERE_USED_MAT'
exporting
datub = sy-datum
datuv = sy-datum
matnr = matnr
postp = ' '
stlan = ' '
werks = werks
stltp = ' '
importing
topmat = selpool "Not Currently Used
tables
wultb = itab
equicat = eqpcat "Not Currently Used
kndcat = kndcat "Not Currently Used
matcat = matcat "Not Currently Used
stdcat = stdcat "Not Currently Used
tplcat = tplcat "Not Currently Used
prjcat = prjcat "Not Currently Used
exceptions
material_not_found = 02
no_where_used_rec_found = 03
no_where_used_rec_selected = 04
no_where_used_rec_valid = 05.
endform.
Regards,
Rich Heilman
2006 Jul 11 3:53 PM
Hi Rich,
The code is helpful but I get more than one parent
material. Is there a way to get the parent material
depending on which project it is being used?.
What I actually need is just the parent material
of the components which have project stocks.
I was able to get the project stock using
the table MSPR but I also need to get the
parent of these components. The parent of the
component should be the one which exists in network
order. (in Transaction CJ20). I was able to manually look trace the parent materiall using MD04, choose
procject stock then show the pegged requirements.
Maybe you know a better way to do it?
Thank you so very very much for your help.
Best Regards,
Rose
2006 Jul 11 3:58 PM
Getting multple parents is the basic functionality of the WHERE USED function module, because your component can reside in any number of BOMs. If you have specific requirements to narrow down to one specific parent, then you will need to come up with the logic, but you should still use the function module i have suggested.
Please make sure to award points for helpful answers.
Regards,
Rich Heilman
2006 Jul 11 4:03 PM
Hi,
try with function module BOM_HIERARCHY .
in the table parameters we can get the materials involved in this BOM and their level indicator in STUFE field, by checking this we can find the top-most level material.