Our customer is using the 4.0 SP1 now and they are getting a strange error when trying to change the Ship-To Code on the Sales Order card.
It says "Reservation Entry Already Exists Error Identification Fields and Values Entry No.246013, Positive 'No'".
When tried again, the error is still the same, but the Entry No would be different...maybe say 246014.
Then, they stopped, and tried again, and from time to time, it went through without that error. But if they would try again, the error comes back with different entry no.
I used debugger to trace the problem and the error breaks at the following codes (label A):
But if all had been deleted in (label

, why would it say "entry already exists"?
Please note that this function is being called twice from another function called RecreateSalesLines(ChangedFieldName)
First time it was called like this
RecreateReservEntry(SalesLine, 0, TRUE);
Second time it was called like this:
RecreateReservEntry(SalesLineTmp, SalesLine."Line No.", False);
ReservEntry and TempReservEntry are both Global variable.
Both RecreateSalesLines and RecreateReservEntry are functions in the Sales Header table.
Has anyone seen this error before? Any insight? Would really appreciate your input.
RecreateReservEntry(OldSalesLine : Record "Sales Line";NewSourceRefNo : Integer;ToTemp : Boolean)
IF ToTemp THEN BEGIN
CLEAR(ReservEntry);
ReservEntry.SETCURRENTKEY("Source ID","Source Ref. No.","Source Type","Source Subtype");
ReservEntry.SETRANGE("Source ID",OldSalesLine."Document No.");
ReservEntry.SETRANGE("Source Ref. No.",OldSalesLine."Line No.");
ReservEntry.SETRANGE("Source Type",DATABASE::"Sales Line");
ReservEntry.SETRANGE("Source Subtype",OldSalesLine."Document Type");
IF ReservEntry.FIND('-') THEN
REPEAT
TempReservEntry := ReservEntry;
TempReservEntry.INSERT;
UNTIL ReservEntry.NEXT = 0;
ReservEntry.DELETEALL; //[Label B]
END ELSE BEGIN
CLEAR(TempReservEntry);
TempReservEntry.SETCURRENTKEY("Source ID","Source Ref. No.","Source Type","Source Subtype");
TempReservEntry.SETRANGE("Source Type",DATABASE::"Sales Line");
TempReservEntry.SETRANGE("Source Subtype",OldSalesLine."Document Type");
TempReservEntry.SETRANGE("Source ID",OldSalesLine."Document No.");
TempReservEntry.SETRANGE("Source Ref. No.",OldSalesLine."Line No.");
IF TempReservEntry.FIND('-') THEN
REPEAT
ReservEntry := TempReservEntry;
ReservEntry."Source Ref. No." := NewSourceRefNo;
ReservEntry.INSERT; //[LABEL A] <--ERROR breaks here
UNTIL TempReservEntry.NEXT = 0;
TempReservEntry.DELETEALL;
END;
Comments
rgds,
Johnson Alonso
sea-navision-community-subscribe@yahoogroups.com
detail in:
http://sea-navision-community.blogspot.com
rgds,
sea-navision-community-subscribe@yahoogroups.com
detail in:
http://sea-navision-community.blogspot.com
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
We don't use Location code and Lot. No. And i also checked, the Positive field is not checked. And i have also checked the line, there was no Reservation on each line.
I tried to create a fresh Sales Order with several line items both on 3.7 and 4.0. THe one i created on 3.7 always work. But the one on 4.0....give error even when renaming the Sell-to Customer No field and the Ship-to Code field. I can imagine the same error if i try to rename other field on Sales Header.
I did an experiment on both 3.7 and 4.0.
Each time a new Sales Order is created, an entry is created in Reservation Table like this:
Entry No. Positive Item No. Reservation Status
=============================================
243074 No 603-500215 Surplus
And everytime i rename the same fields on 3.7, it always work.
So i open the affected codes in 3.7 and 4.0 and found out there is one difference in the code.
All the affected line of codes are the same in both 3.7 and 4.0 EXCEPT one missing filter in 4.0 SP1 that caused the problem. So i put that filter back in 4.0 SP1 and it works now. But i don't know what this might cause since if that line was deleted in 4.0, it might mean something, right?
RecreateReservEntry(OldSalesLine : Record "Sales Line";NewSourceRefNo : Integer;ToTemp : Boolean)
IF ToTemp THEN BEGIN
CLEAR(ReservEntry);
ReservEntry.SETCURRENTKEY("Source Type","Source Subtype","Source ID");
ReservEntry.SETRANGE("Source Type",DATABASE::"Sales Line");
ReservEntry.SETRANGE("Source Subtype",OldSalesLine."Document Type");
ReservEntry.SETRANGE("Source ID",OldSalesLine."Document No.");
ReservEntry.SETRANGE("Source Ref. No.",OldSalesLine."Line No.");
ReservEntry.SETRANGE("Reservation Status",ReservEntry."Reservation Status"::Reservation); <--missing in 4.0 SP1
IF ReservEntry.FIND('-') THEN
REPEAT
TempReservEntry := ReservEntry;
TempReservEntry.INSERT;
UNTIL ReservEntry.NEXT = 0;
ReservEntry.DELETEALL;
END ELSE BEGIN
CLEAR(TempReservEntry);
TempReservEntry.SETCURRENTKEY("Source Type","Source Subtype","Source ID");
TempReservEntry.SETRANGE("Source Type",DATABASE::"Sales Line");
TempReservEntry.SETRANGE("Source Subtype",OldSalesLine."Document Type");
TempReservEntry.SETRANGE("Source ID",OldSalesLine."Document No.");
TempReservEntry.SETRANGE("Source Ref. No.",OldSalesLine."Line No.");
TempReservEntry.SETRANGE("Reservation Status",TempReservEntry."Reservation Status"::Reservation); <---this part is missing from 4.0 SP1
IF TempReservEntry.FIND('-') THEN
REPEAT
ReservEntry := TempReservEntry;
ReservEntry."Source Ref. No." := NewSourceRefNo;
ReservEntry.INSERT;
UNTIL TempReservEntry.NEXT = 0;
TempReservEntry.DELETEALL;
END;
I encounter a related problem with the Reservation Entry table in 4.00 SP2.
(See my latest posting). I have the feeling that SP1 and/or SP2 is doing some weird things. I am not able to use a simple setrange and if .. find('-') statement. The filters are set in a correct way (I double check many times) but it didn't work. When I copy over the EXACT same code into a standalone codeunit it works fine.
It beats me.