I'm not sure if this gives the correct results. I can't compare it to anything but it should give you something to start with.
;WITH Sample AS(
SELECTI.StockCode,
B.ParentPart,
B.Component,
B.QtyPer,
B.Route,
0 AS [level]
from #BomSteve B
JOIN #InvSteve I ON I.StockCode = B.ParentPart
UNION ALL
SELECTs.StockCode,
B.ParentPart,
B.Component,
B.QtyPer,
B.Route,
s.[level] + 1 AS [level]
from Sample s
JOIN #BomSteve B ON s.Component = B.ParentPart
)
SELECT *
FROM Sample
ORDER BY StockCode, [level], ParentPart, Component