I have been trying to update Expected cost for each item. Not able to achieve this ! Pls help !!

atpiyush
Member Posts: 12
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
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
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions