We use Navision 3.70A SQL Server option.
Sometimes invoices we try to post give an error message: "Item Tracking Serial No. <...> Lot No. <...> for Item No. <...> Variant cannot be fully applied". I turned the debugger on and followed through the code in Codeunit 22 - ApplyItemLedgEntry(). There I saw a strange thing happend with a record variable ItemLedgEntry2. At the beginning we put some filters on it and make a FIND('-') - we get two records in the dataset and the variable points at the first record of it. Then we make a copy of ItemLedgEntry2 to OldItemLedgEntry.
Then we modify the "Open" field of OldItemLedgEntry which is a current key field of ItemLedgEntry2. As I get it, nothing should be changed within ItemLedgEntry2, despite on a new value of "Open" key field - we still must have two records in our dataset assosiated with ItemLedgEntry2. On the second step of the REPEAT/UNTIL loop we must step to the second record of ItemLedgEntry2 (I suppose it still must be there - dataset remains the same) but this
IF ItemLedgEntry2.NEXT =0 THEN EXIT;
line of code exits the codeunit somehow. So, as we don't process the second record of ItemLedgEntry2 we have an error described in the topic title.
I try to simulate this issue but my code runs correctly:
ItemLedgEntry2.RESET;
ItemLedgEntry2.SETCURRENTKEY("Item No.","Variant Code",Open,Positive,"Location Code","Posting Date");
ItemLedgEntry2.SETRANGE("Item No.",'6946');
ItemLedgEntry2.SETRANGE("Variant Code",'');
ItemLedgEntry2.SETRANGE(Open,TRUE);
ItemLedgEntry2.SETRANGE(Positive,TRUE);
ItemLedgEntry2.SETRANGE("Location Code",'CENTER');
ItemLedgEntry2.SETRANGE("Lot No.",'000907/1970905');
ItemLedgEntry2.SETFILTER("Entry No.",'<>%1',186145);
IF ItemLedgEntry2.FIND('-') THEN
BEGIN
MESSAGE('%1',ItemLedgEntry2.COUNT); // =2 records
OldItemLedgEntry.COPY(ItemLedgEntry2);
OldItemLedgEntry.Open := FALSE;
OldItemLedgEntry.MODIFY;
REPEAT
MESSAGE('Before=%1',ItemLedgEntry2."Entry No.");
MESSAGE('STEP'); // = appears 2 times
IF ItemLedgEntry2.NEXT=0 THEN
BEGIN
MESSAGE('NONE');
EXIT;
END;
MESSAGE('After=%1',ItemLedgEntry2."Entry No.");
OldItemLedgEntry.COPY(ItemLedgEntry2);
OldItemLedgEntry.Open := FALSE;
OldItemLedgEntry.MODIFY;
UNTIL FALSE;
MESSAGE('%1',ItemLedgEntry2.COUNT);
END;
I don't understand what is wrong in Codeunit 22 - ApplyItemLedgEntry().
Any suggestions will be very much appreciated.
Thanks in advance.
Comments
The next solution is probably worth to try (where LastEntryNo is a new variable, type Integer):
My blog
What is a nature of this bug? Is there a detail description of it and some solution to fix it?
http://www.mibuso.com/forum/viewtopic.php?t=6267
It is working, I spend few hours looking for source of same problem on site, after I used this hack, all was working correctly...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Yep, it really worked. I had a value of 65535 in the "Diagnostics" field, I set it manually as I read about it from Navision KB at the partnersource once - it fixes BULK INSERT bug. But I don't know what things does this value affect. Does anyone know what is the purpose of this field and its different values in the "$ndo$property" table?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.