Sir,
The following Standard Code in NAV is occasionally used to find the LAST No. (read Last PK) of the targeted* table.
* in where the programme is going to INSERT the records.
IF ItemLedgEntryNo = 0 THEN BEGIN
GlobalItemLedgEntry.LOCKTABLE;
IF GlobalItemLedgEntry.FINDLAST THEN
ItemLedgEntryNo := GlobalItemLedgEntry."Entry No.";
END;
May I know why does NAV use the First Line --"IF ItemLedgEntryNo = 0" in the beginning ?
What will be the problem if the mentioned is removed ?
Kindly reply.
Thanks.
Comments
If there is a problem if you remove it depends on the exact situation, and if it is somewhere in the posting process like Cu 22 it is hard to tell.
Anyway i see no reason to remove it in first place, bad idea imo.
Apart from your (Technical) opinions I have come to know the below function part also.
A LOCKTABLE in SQL Server does not lock anything. It's used to set the SET TRANSACTION ISOLATION LEVEL(SERIALIZABLE).
When we post a (Batch Posting) Item Journal Lines/Gen. Journal Lines, we all know that the posted entries(Item Ledger Entry & G/L Entry) are (should be) in Sequence in PK.
If we remove the mentioned line from the code then there is a possibility for the system to have a GAP in PK sequence.