• So is this a custom built system, or are you modifying an off the shelf product?

    I'm making a few assumptions here:

    1. You know how to identify "top level" items.

    2. Your structure lets you find all children one level down from a given level

    What I did to solve a problem very similar to yours was:

    1. create a temp table with your item ids and a "level" variable

    2. seed your temp table with the top level item(s) at level 0 that you want to calculate a BOM for.

    do:

    3. increment level

    4. join from temp table back to source table to find all children where parent item is in level - 1 and insert into temp table with current level

    until records returned is 0

    this lets you explore all branches of all sub boms in a stored procedure, non-recursive way, and at the end, you can simply select everything from your temp table that is not a phantom.

    I hope I understood your problem correctly, and I hope this helps.