Subject Production
Author Melissa Torn
I have below bill of material for an Assembly item
AAA  ( Main Assy Item )
   A1    (Sub Assy Item under Main Assy Item
       A2  (Sub Assy Item under A1)
           A3 (Sub Assy Item under A2)
               A4 (Sub Assy Item Under A3)

For Example  I have below recursive query result
ITEMNO  ITEMSTOCK  CHILDITEMNO  CHILDSTOCK
AAA                     0             A1                             0
A1                        0             A2                             0       
A2                        0             A3                             1
A3                        1             A4                             0

I want to use Sub Assies Stocks if their stock > 0 in the production

My problem is i cant follow the subassies chain, for example
if A1 Stock >= Manufacturing Quantitiy then i should not need to manufacture A2, A3,A4
if A1 Stock <  Manufacturing Quantitiy and A3 Stock >=Manufacturing Quantity then i should not to manufacture  A3
......

Can someone please help me regarding an algoritma or a sample code.

Thank You