Finding Available Inventory when posting sales order
slmaluwa
Member Posts: 366
hello
I am trying to get the available qty of an item at a particular location at the time posting the order. Earlier another developer has used ItemLedgerEntry as follows:
Now, can't I do the same think in a much faster way using this method?
Do you see any mistake here. I think it doesn't return the qty as required.
I am trying to get the available qty of an item at a particular location at the time posting the order. Earlier another developer has used ItemLedgerEntry as follows:
dvQTY := 0;
recItemLedger.RESET;
recItemLedger.SETCURRENTKEY("Item No.","Entry Type","Variant Code","Drop Shipment","Location Code","Posting Date");
recItemLedger.SETRANGE("Item No.",recSalesLine."No.");
recItemLedger.SETRANGE("Variant Code",recSalesLine."Variant Code");
recItemLedger.SETRANGE("Location Code",recSalesLine."Location Code");
recItemLedger.SETFILTER("Remaining Quantity",'<>0');
IF recItemLedger.FIND('-') THEN BEGIN
REPEAT
DVQty := DVQty + recItemLedger."Remaining Quantity";
UNTIL recItemLedger.NEXT = 0;
END;
Now, can't I do the same think in a much faster way using this method?
recItem.RESET;
recItem.SETRANGE("No.",recSalesLine."No.");
recItem.SETFILTER("Location Filter",recSalesLine."Location Code");
IF recItem.FIND('-') THEN
recItem.CALCFIELDS(Inventory);
DVQty := recItem.Inventory;
recItem.RESET;
Do you see any mistake here. I think it doesn't return the qty as required.
"A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."
0
Comments
-
Yes, you miss Variant code.
Actually it is better to use CALCSUMS in original developer code
0 -
Hi
Yes, I missed it. Actually, I am yet to understand what exactly this Variant means? Never came across it and the company also only interested in the cost of item in a location
So, suppose, I also add "Variant filter". Which code you recommend to use?"A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."0 -
Or trying to be perfect replace FIND(‘-’) with a FINDFIDST0
-
dvQTY := 0; recItemLedger.RESET; recItemLedger.SETCURRENTKEY(change this key to to what that has the following fields and has remaining qty as sumindex field); recItemLedger.SETRANGE("Item No.",recSalesLine."No."); recItemLedger.SETRANGE("Variant Code",recSalesLine."Variant Code"); recItemLedger.SETRANGE("Location Code",recSalesLine."Location Code"); recItemLedger.SETRANGE(Open,,true); recItemLedger.calcsums("remaining quantity"); dvQTY := recItemLedger."remaining quantity";0 -
Why do you need this? If it is just informative then ok.
Where is it going to be used?0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
