Adjust Cost Item Entries in NAV 4.0 SP3 - Endless Loop

mel_sadek
Member Posts: 23
Hi all,
I have a client that is running into an endless loop when running Adjust Cost Item Entries on a few specific items. As is the case with these endless loop, the costing method is Average. And yes, I have read all of the relevant material here on MIBUSO and Microsoft's Hotfix in KB978605. I applied the recommended hotfix, but surprisingly, it didn't solve the problem. I also realized that the code Microsoft recommends to delete doesn't exist in the 5895 codeunit, even though the database and client are 4.3, so I did my best to apply the patch. Obviously, it's not working. I would like to get your opinion and advice on what may have went wrong in the hotfix patching. I enclosed the code that I patched below. Kindly please review the code and let me know if and where it went all wrong.
I sincerely appreciate all your efforts and help. This won't be forgotten.
AvgValueEntriesToAdjustExist:
IsExcludeEntryFromAvgCostCalc:
UpdateAvgCostAdjmtEntryPoint:
I have a client that is running into an endless loop when running Adjust Cost Item Entries on a few specific items. As is the case with these endless loop, the costing method is Average. And yes, I have read all of the relevant material here on MIBUSO and Microsoft's Hotfix in KB978605. I applied the recommended hotfix, but surprisingly, it didn't solve the problem. I also realized that the code Microsoft recommends to delete doesn't exist in the 5895 codeunit, even though the database and client are 4.3, so I did my best to apply the patch. Obviously, it's not working. I would like to get your opinion and advice on what may have went wrong in the hotfix patching. I enclosed the code that I patched below. Kindly please review the code and let me know if and where it went all wrong.
I sincerely appreciate all your efforts and help. This won't be forgotten.
AvgValueEntriesToAdjustExist:
... IF FIND('-') THEN BEGIN FindNextRange := TRUE; SETRANGE("Valuation Date","Valuation Date"); REPEAT IF "Item Charge No." = '' THEN BEGIN IF "Valued By Average Cost" AND NOT Adjustment AND ("Valued Quantity" < 0) THEN BEGIN OutbndValueEntry := ValueEntry; OutbndValueEntry.INSERT; FindNextRange := FALSE; END; // GRA1.01 - Add Start // Add the following lines. IF ("Entry Type" = "Entry Type"::Revaluation) OR NOT (("Item Ledger Entry Type" = "Item Ledger Entry Type"::Transfer) AND InvtSetup.IsAvgCostCalcTypeItem) THEN BEGIN ExcludedValueEntry := ValueEntry; ExcludedValueEntry.INSERT; END; // End of the added lines. // GRA1.01 - Add End // GRA1.01 - Delete Start { IF "Partial Revaluation" OR "Valued By Average Cost" THEN BEGIN ExcludedValueEntry := ValueEntry; ExcludedValueEntry.INSERT; END; } // GRA1.01 - Delete End END; UNTIL NEXT = 0; END; IF FindNextRange THEN BEGIN AvgCostAdjmtEntryPoint."Valuation Date" := GetNextDate("Valuation Date"); AvgValueEntriesToAdjustExist(OutbndValueEntry,ExcludedValueEntry,AvgCostAdjmtEntryPoint); END; ...
IsExcludeEntryFromAvgCostCalc:
... WITH ValueEntry DO BEGIN IF "Partial Revaluation" THEN EXIT(TRUE); IF "Item Ledger Entry No." = OutbndValueEntry."Item Ledger Entry No." THEN EXIT(TRUE); // GRA1.01 - Add Start IF "Item Ledger Entry Type" = "Item Ledger Entry Type"::Transfer THEN IF Adjustment AND ("Applies-to Entry" < OutbndValueEntry."Entry No.") THEN EXIT(FALSE); // GRA1.01 - Add End IF NOT "Valued By Average Cost" THEN EXIT(FALSE); // GRA1.01 - Delete Start { IF NOT InvtSetup.IsAvgCostCalcTypeItem AND ("Item Ledger Entry Type" = "Item Ledger Entry Type"::Transfer) AND ("Valued Quantity" >= 0) THEN EXIT(FALSE); } // GRA1.01 - Delete End ...
UpdateAvgCostAdjmtEntryPoint:
... // GRA1.01 - Delete Start { AvgCostAdjmtEntryPoint.UpdateValuationDate( ValueEntry,IsAvgCostItem,InvtSetup.IsAvgCostCalcTypeItem); } // GRA1.01 - Delete End // GRA1.01 - Add Start // Add the following lines. IF (ValueEntry."Item Ledger Entry Type" = ValueEntry."Item Ledger Entry Type"::Transfer) AND InvtSetup.IsAvgCostCalcTypeItem THEN EXIT; AvgCostAdjmtEntryPoint.UpdateValuationDate(ValueEntry,IsAvgCostItem,InvtSetup.IsAvgCostCalcTypeItem); // End of the added lines. // GRA1.01 - Add End
0
Comments
-
Is the database a new implementation? Did you just update from a previous version? Why does the problem appear right now?
I've experienced, that endless loops can appear when entries are manipulated incorrectly. Such as deleted item ledger entries or modified closed by entry no field. The same for item application entries.
You can trace the entries causing the problem using the debugger. Then check if all fields and relations are plausible.
Here its helpful if you would run adjust cost for only that item which causes the problem. I could give you a code for that on tuesday0 -
Hi herrlutz,
Thanks for the quick feedback. To answer your last point, yes I am running the Adjust Cost Item Entries routine for a singular item. The modification put in is similar to the way it was implemented in NAV 5.0, and it's also similar to how ara3n coded it on this forum. So no worries there...
Regarding the database, this was not a new implementation, and it has been going on for a while actually. I used the debugger and was able to find several value entries that the system keeps looping through time and time again. I know how many there are and what they are. The main challenge here is that I wasn't around when any potential manipulation was done to the system, so I cannot figure out where to start. However, maybe correcting the code above (if there's something wrong with it) would be a good start to solving this mystery.
0 -
are you using Manufacturing? If yes, by any chance you posted the Consumption and output has the same item? In one my client place the same thing happened and Adjust cost item entries was keep on going in the loop. Finally we found out and resolved.--
Regards,
Raveendran.BS0 -
Hi Raveendran,
The client doesn't use manfuacturing, however one of the items in question that loops endlessly has an assembly BOM. I did take Rashed's advice and ran the Adjust Cost Item Entries report on all components of an item before running it on the master item. Interestingly enough, all components finished adjustment almost instantaneously, but the master item just kept looping endlessly.0 -
Reveendran, herrlutz...any updates from your side?
Anybody else might have a beat on this?0 -
Hello,
We run in an endless Loop caused by a blank Item Number in Tab27 some times ago.
We put Cost is Adjusted = true in this record.0 -
There is something wrong with the creation of Item application entries in NAV. It's a very rare problem but it does occur with unmodified code. It seems to be possibly related to average costing and systems that frequently have the Navision stock level going negative.
If you trace through the "Item application entry" records starting from the Item ledger entry numbers that have the "Applied item to adjust" flag set you should find a loop.
Break the loop.
It's a protected table so you'll need a dev license.Robert de Bath
TVision Technology Ltd0
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