ExistingExpirationDateAndQty Function

BeliasBelias Member Posts: 2,998
edited 2011-11-12 in NAV Three Tier
the function in object, present in codeunit 6500, there's a major threat in performance, if you use the tracking module. Here's the old code (with a lot of data, a single reclassification journal line could post in 20-30 seconds O.o)
IF ItemLedgEntry.FINDSET THEN
  REPEAT
    SumOfEntries += ItemLedgEntry."Remaining Quantity";
  UNTIL ItemLedgEntry.NEXT = 0;

here's how i modified it:
ItemLedgEntry.CALCSUMS("Remaining Quantity");
  SumOfEntries := ItemLedgEntry."Remaining Quantity";
//IF ItemLedgEntry.FINDSET THEN
  //REPEAT
  //  SumOfEntries += ItemLedgEntry."Remaining Quantity";
  //UNTIL ItemLedgEntry.NEXT = 0;

I'm wondering why it wasn't done in "my" way...any idea? Am I missing something, maybe?
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • reijermolenaarreijermolenaar Member Posts: 256
    Hi Belias,

    It will work fine on an SQL database but on a C/SIDE database you will get an error that you must select the right key.
    Reijer Molenaar
    Object Manager
  • BeliasBelias Member Posts: 2,998
    for sure, that may be the reason (not tested, but i trust you because that key does not have the sumindex for remaining qty) :mrgreen: ...
    anyway..the performance boost is so freakin' huge that they should have done a RECORDLEVELLOCKING switch for it, at least...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.