PROCEDURE ProcessBOM LPARAMETERS lcBomNo LOCAL lnArrayLen, lnCounter, lnTotalCost LOCAL ARRAY aBomDetail(1,5) && scope array to local procedure * Select data into array SELECT pebmdt01.item,pebmdt01.begdate, pebmdt01.bqtyusd, pebmdt01.umeasurusd, pebmdt01.operid, icitem01.stdcost ; from pebmdt01, icitem01 ; WHERE pebmdt01.bomno = lcBomno ; AND pebmdt01.item = icitem01.item ; ORDER BY icitem01.itmdesc ; INTO ARRAY aBomDetail lnTotalCost = 0 && Initialize cost IF TYPE("aBomDetail") = "C" && Array created will be "U" if no records returned? * Get count of items/assemblies returned lnArrayLen = ALEN(aBomDetail,1) * Assign item field to temorary variable lcItem = aBomDetail(lncounter,1) * Loop through all items/assemblies FOR lnCounter = 1 TO lnArrayLen && Loop through assembly SELECT pebmhd01 && Check for sub assembly locate for pebmhd01.bomno = aBomDetail(lnCounter,1) IF !EOF() && There is a subassembly so process it lnTotalCost = lnTotalCost + ProcessBOM(lcItem) && Recursive call Do UpdateCost with lcItem, lnTotalCost && update cost after rollup ELSE lnTotalCost = lnTotalCost + aBomDetail(lnCounter,6) && add stdcost to total ENDIF * add item to BOM cursor for the report Do BOMAdd lcitem, aBomDetail(lncounter,4) && This "C" field appears volatile ENDFOR ENDIF RETURN lnTotalCostThanks in advance for any help on this. It's making me pull my hair out! :)