Alternate way to run codeunit for update the custom field(Available Inventory) in item table.

ManiNav
Member Posts: 120
Hi Everyone,[NAV 2009]
I have to update Custom field(Available inventory) of item table continuously. so, i created codeunit to run by jobqueue by every 5 min., but this activity became deadlock or this job became stop due to modifying anything in item table by another user.
My codeunit: with property: singleinstance=yes;
IF Item.FINDFIRST THEN
REPEAT
Item.CALCFIELDS(Inventory,"Qty. on Sales Order");
Item."Available Inventory" := Item.Inventory - Item."Qty. on Sales Order" - Item.Buffer;
Item.MODIFY;
UNTIL Item.NEXT = 0;
So, I tried to run codeunit directly by NAS.
for this I add code in codeunit:Application Management(1):
SRSetup.GET;
IF SRSetup."Run Available Inventory" THEN BEGIN
CODEUNIT.RUN(CODEUNIT::"NAS AvailableInventory_Kar");
MESSAGE('NAS Available Inventory Started');
END;
But ,this is now even updating the field. Once I restart the NAS-service,then only first time it use to update item table field after that not effecting. I check in Eventviewer,i am getting the MESSAGE 'NAS Available Inventory Started' as i put in codeunit 1 to run my codeunit.
Please check and guide me whether i am on right path or guide me further.
your help will be very-very appreciable..plse guide me.
Thanks,
Mani
I have to update Custom field(Available inventory) of item table continuously. so, i created codeunit to run by jobqueue by every 5 min., but this activity became deadlock or this job became stop due to modifying anything in item table by another user.
My codeunit: with property: singleinstance=yes;
IF Item.FINDFIRST THEN
REPEAT
Item.CALCFIELDS(Inventory,"Qty. on Sales Order");
Item."Available Inventory" := Item.Inventory - Item."Qty. on Sales Order" - Item.Buffer;
Item.MODIFY;
UNTIL Item.NEXT = 0;
So, I tried to run codeunit directly by NAS.
for this I add code in codeunit:Application Management(1):
SRSetup.GET;
IF SRSetup."Run Available Inventory" THEN BEGIN
CODEUNIT.RUN(CODEUNIT::"NAS AvailableInventory_Kar");
MESSAGE('NAS Available Inventory Started');
END;
But ,this is now even updating the field. Once I restart the NAS-service,then only first time it use to update item table field after that not effecting. I check in Eventviewer,i am getting the MESSAGE 'NAS Available Inventory Started' as i put in codeunit 1 to run my codeunit.
Please check and guide me whether i am on right path or guide me further.
your help will be very-very appreciable..plse guide me.
Thanks,
Mani
0
Answers
-
This seems so wrong. Are you sure you need to have that field and update it every 5 minutes?
This will cause blocking for sure because you are updating all the records.
If you really need to do this, then well least check if the Available Inventory needs to be updated and update only when needed.
IF Item.FINDFIRST THEN
REPEAT
Item.CALCFIELDS(Inventory,"Qty. on Sales Order");
IF Item.”Available Inventory” <> Item.Inventory - Item.”Qty. on Sales Order” - Item.Buffer THEN BEGIN
Item."Available Inventory" := Item.Inventory - Item."Qty. on Sales Order" - Item.Buffer;
Item.MODIFY;
END;
UNTIL Item.NEXT = 0;0 -
Hi ricardopaiva,
Thanks for the guide. I will do the same as your suggestion and will update if it will work fine ie. without interruption.
Thanks,
Mani.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions