Is there any setup in Navision3.7 to stop the transactions which are going to create a negative inventory?
Use "Lot Tracking" on all items. The systems does not allow "Lot Tracked" items to go negative. You may need to re-think some of the business process to support this change.
Hello I've done this for many clients as Mattrax mentioned it's in CU 22 function InsertItemLedgEntry.
The function already does not allow negative inventory for consumption entries.
IF (((ItemLedgEntry."Entry Type" IN
[ItemLedgEntry."Entry Type"::"Negative Adjmt.",
ItemLedgEntry."Entry Type"::Consumption]) AND
("Source Type" = "Source Type"::Item)) OR
(ItemLedgEntry."Entry Type" = ItemLedgEntry."Entry Type"::Transfer)) AND
(ItemLedgEntry.Quantity < 0)
THEN
ERROR(Text005,ItemLedgEntry."Item No.");
text005 is 'Item %1 is not on inventory.'
You add your own code below it.
//Mod Start
if (ItemLedgEntry.Quantity < 0) THEN
ERROR(Text005,ItemLedgEntry."Item No.");
//Mod End[/code]
Ahmed Rashed Amini
Independent Consultant/Developer
I wouldn't do it this way. Just follow the code example I've written above.
One problem with your code is, what they are already negative on inventory?
They will get the error no matter what.
//Mod Start
IF NOT InvtSetup."Allow Neg. Invt." THEN
if (ItemLedgEntry.Quantity < 0) THEN
ERROR(Text005,ItemLedgEntry."Item No.");
//Mod End
Plus your code is slow. You are doing calculating a flow field for every entry.
Ahmed Rashed Amini
Independent Consultant/Developer
Hello I've done this for many clients as Mattrax mentioned it's in CU 22 function InsertItemLedgEntry.
The function already does not allow negative inventory for consumption entries.
IF (((ItemLedgEntry."Entry Type" IN
[ItemLedgEntry."Entry Type"::"Negative Adjmt.",
ItemLedgEntry."Entry Type"::Consumption]) AND
("Source Type" = "Source Type"::Item)) OR
(ItemLedgEntry."Entry Type" = ItemLedgEntry."Entry Type"::Transfer)) AND
(ItemLedgEntry.Quantity < 0)
THEN
ERROR(Text005,ItemLedgEntry."Item No.");
text005 is 'Item %1 is not on inventory.'
You add your own code below it.
//Mod Start
if (ItemLedgEntry.Quantity < 0) THEN
ERROR(Text005,ItemLedgEntry."Item No.");
Comments
Deep
India
No Standard code in any version???
Deep
India
Use "Lot Tracking" on all items. The systems does not allow "Lot Tracked" items to go negative. You may need to re-think some of the business process to support this change.
If I want to put my code then where is write place in Codeunit 22 to check the same.
In which function of codeunit 22 I use to write my code.
That said, if you are the only one who can do it, there is a function in C22 called InsertItemLedgEntry. Be careful.
The function already does not allow negative inventory for consumption entries.
text005 is 'Item %1 is not on inventory.'
You add your own code below it.
//Mod End[/code]
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I have choosen the right function.
And my code is
InvtSetup.GET;
Item.GET(ItemLedgEntry."Item No.");
Item.SETFILTER("Date Filter",'..%1', ItemJnlLine."Posting date");
Item.SETFILTER("Location Filter",'%1',ItemLedgEntry."Location Code");
Item.CALCFIELDS("Net Change");
IF NOT InvtSetup."Allow Neg. Invt." THEN
IF (Item."Net Change" + ItemLedgEntry.Quantity) < 0 THEN
ERROR(Text005A,Item."No.",ItemJnlLine."Posting Date");
Text005A =
The quantity in the Inventory is not sufficient to cover net change in the inventory
for Item No. %1 on date %2.';
One problem with your code is, what they are already negative on inventory?
They will get the error no matter what.
Plus your code is slow. You are doing calculating a flow field for every entry.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Out of the box, you can enable warehouse management. This will prevent inventory from going negative.
Search the forum, there are a TON of discussions on this.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book