Each item have a BOM and inside the BOM there will be other items which will also have BOM....so we need to update the last item first which do not have BOM and then we will move upward in flow chart until unless every item in BOM of first item gets updated. Then the item for which we use one action button to update expected cost gets updated, in the end.
It is difficult to explain, (please see the attached file) but if any one of you have faced the same requirement anytime, Kindly please help me. I have tried to wrote a code as well for the same but do not know how to complete code & requirement both.
*******************************************************************************************************************
LevelLocal := 0;
Item_Level_Local := 0;
TotalExpectedCostLocal := 0;
GetBOMItemsExpectedCost(Item);
Item - OnPostDataItem()
Item."Expected Cost" := TotalExpectedCostLocal;
Item.MODIFY;
LOCAL GetBOMItemsExpectedCost(ItemPara : Record Item)
LevelLocal := LevelLocal + 1;
Item_Level_Local := Item_Level_Local + 1;
CLEAR(ItemLocal[Item_Level_Local]);
ItemLocal[Item_Level_Local].SETRANGE("No.",ItemPara."No.");
IF ItemLocal[Item_Level_Local].FINDFIRST THEN;
IF ItemLocal[Item_Level_Local]."Production BOM No." <> '' THEN BEGIN
CLEAR(ProductionBOMLineLocal[LevelLocal]);
ProductionBOMLineLocal[LevelLocal].SETRANGE("No.",ItemLocal[Item_Level_Local]."Production BOM No.");
IF ProductionBOMLineLocal[LevelLocal].FINDSET THEN BEGIN
REPEAT
Item_Level_Local += 1;
CLEAR(ItemLocal[Item_Level_Local]);
ItemLocal[Item_Level_Local].SETRANGE("No.",ProductionBOMLineLocal[LevelLocal]."No.");
IF ItemLocal[Item_Level_Local].FINDFIRST THEN BEGIN
IF ItemLocal[Item_Level_Local]."Production BOM No." <> '' THEN
GetBOMItemsExpectedCost(ItemLocal[Item_Level_Local])
ELSE
TotalExpectedCostLocal += ItemLocal[Item_Level_Local]."Expected Cost";
END;
Item_Level_Local -= 1;
UNTIL ProductionBOMLineLocal[LevelLocal].NEXT = 0;
LevelLocal -= 1;
END;
END ELSE BEGIN
TotalExpectedCostLocal += ItemLocal[Item_Level_Local]."Expected Cost";
Item_Level_Local -= 1;
LevelLocal -= 1;
END;
*******************************************************************************************************************
I have attached a file where you can see how the FLOWCHART is representing...To calculate the expected cost of Item 1, we need to calculate expected cost of first Item 9 & Item 8 which will be in this case equal to unit cost as they do not have any BOM. Then, Item 5 expected cost will be sum of the expected cost of Item 8 and Item 9....
and this way it will move further to Item 1.
Thanks in Advance,
Regards,
Piyush Agrawal
0