if I am not wrong u r looking to explode bom for a material which has its components extended to other plants...even I had this same scenario and after trying to find a FM for about a week I din get so I hard coded it.
I) Make sure all STO materials have been assigned with a special procurement key '40'.
ii) explode the BOM of material in the selection screen using a FM. (In my case I did it with cs_bom_expl_mat_v2) loop the internal table and get the data from the FM.
III) If u r procuring the material from another plant surely u will have a storage location assigned to it so restrict using if condition.
code I used.
loop at t_stpox into w_stpox. (t_stpox is an internal table of type stpox)
if w_stpox-lgpro = '5034' ('lgpro' is the storage location field in STPOX structure and 5034'' is the storage location of STO items in my company)
iv) push the values of w_stpox into another work area .
w_mast1-matnr = w_stpox-idnrk.
w_mast1-werks = w_stpox-werks.
w_mast1-stlal = w_stpox-stlal.
w_mast1-stlan = w_stpox-stlan.
(Here mast1 is an work area I created of table type mast
)
after pushing the values into the new work area again call the same FM u used. (in my case I used cs_bom_expl_mat_v2 again)
call function cs-BOM_EXPL_MAT_V2.
EXPORTING
capid = 'PP01'
datuv = sy-datum
mehrs = 'X'
mtnrv = w_mast1-matnr
stlal = w_mast1-stlal
stlan = w_mast1-stlan
werks = w_mast1-werks
TABLES
stb = t_stpox1 (table I created of structure stpox)
v) u can loop this table again into ur work area and get the components of the other plant material and exit the loop .