Retaining Values

I am having problems reatining a value for later use. This is the code:- Documentation() OnPreDataItem() OnAfterGetRecord() CALCFIELDS(Inventory); CurrentLevel := 0; CLEAR(BomLineBuffer); BomLineBuffer.INIT; BomLineBuffer.“Line No.” := LineNo; BomLineBuffer.Level := CurrentLevel; BomLineBuffer.“Item No.” := “No.”; BomLineBuffer.Description := Description; BomLineBuffer.“Qty. Avaliable” := Inventory; BomLineBuffer.“Max Build” := Maxbuild; BomLineBuffer.INSERT; Maxbuild := 99999999999; ExplodeBom(Item); LineNo := LineNo + 1000; OnPostDataItem() ExplodeBom(Item2 : Record Item) Bomcomponent2.SETRANGE(“Parent Item No.”, Item2.“No.”); Bomcomponent2.SETRANGE(Type,Bomcomponent2.Type::Item); CurrentLevel := CurrentLevel+1; IF Bomcomponent2.FIND(’-’) THEN REPEAT LineNo := LineNo + 1000; CLEAR(BomLineBuffer); LastInventory := Item3.Inventory; CLEAR(Item3); IF Item3.GET(Bomcomponent2.“No.”) THEN BEGIN Item3.CALCFIELDS(Inventory); BomLineBuffer.INIT; BomLineBuffer.“Line No.” := LineNo; BomLineBuffer.Level := CurrentLevel; BomLineBuffer.“Item No.” := Bomcomponent2.“No.”; BomLineBuffer.Description := Bomcomponent2.Description; BomLineBuffer.“Qty. Per” := Bomcomponent2.“Quantity per”; BomLineBuffer.“Qty. Avaliable” := Item3.Inventory; IF (Item3.Inventory <> 0) AND (Bomcomponent2.“Quantity per” <> 0) AND NOT(Bomcomponent2.“Bill of Materials”) THEN BEGIN BomLineBuffer.“Qty. Can Construct” := Item3.Inventory/Bomcomponent2.“Quantity per”; IF (Item3.Inventory/Bomcomponent2.“Quantity per” < Maxbuild) THEN Maxbuild := Item3.Inventory/Bomcomponent2.“Quantity per” + Item2.Inventory ; END ELSE IF NOT(Bomcomponent2.“Bill of Materials”) THEN Maxbuild := 0; BomLineBuffer.“Max Build” := Maxbuild; BomLineBuffer.INSERT; IF Bomcomponent2.“Bill of Materials” THEN ExplodeBom(Item3); END; UNTIL Bomcomponent2.NEXT =0; CurrentLevel := CurrentLevel -1; What it does is to fill a temp table with the BOM Components depending on their order in the BOM. But it also works out the maximum you can build “Max Build” Maxbuild := Item3.Inventory/Bomcomponent2.“Quantity per” + Item2.Inventory ; The line above effectivley works out the current inventory of the bomcomponeant and divides it by the quantity per then adds the number of Built items to that, the problem is retaining the parent item’s qty per. Thus allowing me to divide the parent Item’s (ITEM2) inventory by its Qty Per in the BOM and thus work out the maximum that can be built. Getting the Item’s inventory is easy as it is retained in the Item2 record set, but the qty per is lost when Bomcomponent2 is used again when running the function ExplodBOM by itself. This might be hard to read as I am finding it hard to write down, so getting someone else to understand where I am coming from is hard. Any ideas?

Quote: BomLineBuffer.“Qty. Avaliable” := Inventory; BomLineBuffer.“Max Build” := Maxbuild; BomLineBuffer.INSERT; Maxbuild := 99999999999; ExplodeBom(Item); LineNo := LineNo + 1000; Are you not here using an unassigned value MaxBuild in the first record? Should it not be // assign the Default Value Maxbuild := 99999999999; BomLineBuffer.“Qty. Avaliable” := Inventory; BomLineBuffer.“Max Build” := Maxbuild; BomLineBuffer.INSERT; ExplodeBom(Item); LineNo := LineNo + 1000; Should these not be on PreDataItem ? Maxbuild := 99999999999; LineNo :=0; CLEAR(BomLineBuffer); // Clears the Buffer only needs calling once BomLineBuffer.INIT; // Clears the Current record for each new Instance David Cox MindSource (UK) Limite Edited by - David Cox on 2001 Mar 18 04:10:42

Tony use a proccesing report to achieve this just need to determine how many levels your Customer may have at the moment it could be infinate I.E BOM Items In each Level Picnic = Item1 Top Level BOM Item …Tuna Salad Sandwich = Item2 is a BOM …Tuna Mayo = Item3 is also a BOM …Tuna …Mayo …Pepper …Tomatoe …Cucumber …Flask of tea …Tea …Milk …Water MaxBuild = 0 Item1 OnGetRecord Create a report Two passes first one calculates a single MAX quanitity to Build Second Creates and fills a BOM Journal no need for a buffer table SetTableVeiw to primary Key on all Levels Integer SETRANGE(Number,1,2); …Item1 (BOM) = Show only if Detail =Yes …BOM Component …Item2 1st Level …BOM Component if Item2 hads its own BOM …Item3 2nd Level …BOM Component …Item4 3rd Level …BOM Component …Item5 show here the max build for Item1 First pass at each Component level Itemx.CALCFIELDS(Inventory,“Reserved Qty.”,“Bill of Materials”); IF (“Quantity per”<>0)THEN IF((MaxBuild=0) or((Inventory-“Reserved Qty.”)/“Quantity Per” < MaxBuild)AND ((Inventory-“Reserved Qty.”)/“Quantity Per” > 0))THEN IF NOT Itemx.“Bill of Materials” THEN MaxBuild:=ROUND((Inventory-“Reserved Qty”)/“Quantity Per”,1) ELSE MaxBuild:=ROUND((Inventory-“Reserved Qty”)/“Quantity Per”)+Itemx.Inventory,1); Second Pass we know the MaxBuild for this product from existing stock. So just Create a Journal for Inventory and another BOM Journal for the lower level BOMs. IF Integer.Number=2 then BEGIN //Make Item Journal or BOM Journal Line if Itemx is itself a BOM the same Calcfields again and code to only produce enough Components or Sub Components (BOMs) using the “Reserved Qty.” and Inventory to caculate requirement. “Item No.” Quantity := (“Quantity Per”*MaxBuild) etc: END; If your Customer uses Reservations we have reduce the Item Inventory by the reserved stock Qty. There nice and tidy Min code and saves the use of a table Not bad for 3:26am GMT David Cox MindSource (UK) Limite Edited by - David Cox on 2001 Mar 18 04:25:44

Dave, The reaosn I put it into a temporary table was to eleviate the problem of an infinate BOM, So all I did was create a table whose Primary Key was Line No. but also had an integer field called Level. This way I simple inserted each part of the BOM in the table at the correct point and then re-an through it on the second dataitem thus allowing me to produce a report that prints out all the parts of the BOM in the correct order without an defined size. regards Tony