get last purchase price

hhhhhhhqat
Member Posts: 111
i want to get last cost recived for one item , i create function to get this cost , on the trigger i add this code
IF ItemRec.GET(ItemNo) THEN BEGIN
RCPTLINE.RESET;
RCPTLINE.SETRANGE("No.",ItemRec."No.");
IF RCPTLINE.FIND('+') THEN
EXIT(RCPTLINE."Cost per Unit")
END ;
RCPTLINE = Value Entry Table , but it takes long time to get this price
1- Entry No.
2- Item Ledger Entry No.,Entry Type Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Cost Amount (Expected) (ACY),Cost Amount (Actual) (ACY),Cost Amount (Non-Invtbl.)(ACY),Purchase Amount (Actual),Purchase Amount (Expected)
3- Item Ledger Entry No.,Document No.
4- Item No.,Posting Date,Item Ledger Entry Type,Entry Type,Item Charge No.,Location Code,Variant Code Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Purchase Amount (Actual),Item Ledger Entry Quantity
5- Item No.,Posting Date,Item Ledger Entry Type,Entry Type,Item Charge No.,Location Code,Variant Code,Global Dimension 1 Code,Global Dimension 2 Code Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Purchase Amount (Actual)
6- Document No.,Posting Date
7- Item No.,Valuation Date,Location Code,Variant Code Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Expected) (ACY),Cost Amount (Actual) (ACY),Item Ledger Entry Quantity
8- Source Type,Source No.,Item No.,Posting Date,Entry Type Discount Amount,Cost Amount (Non-Invtbl.),Cost Amount (Actual),Cost Amount (Expected),Sales Amount (Actual),Sales Amount (Expected),Invoiced Quantity
9- Item Charge No.,Inventory Posting Group,Item No.
10- Capacity Ledger Entry No.,Entry Type Cost Amount (Actual),Cost Amount (Actual) (ACY)
11- Prod. Order No.
12- Source Type,Source No.,Global Dimension 1 Code,Global Dimension 2 Code,Item No.,Posting Date Discount Amount,Cost Amount (Non-Invtbl.),Cost Amount (Actual),Cost Amount (Expected),Sales Amount (Actual),Sales Amount (Expected),Invoiced Quantity
13- Item Ledger Entry Type,Location Code,Product Group,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
14- Item Ledger Entry Type,Offer No.,Item No.,Variant Code Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
15- Item Ledger Entry Type,Salespers./Purch. Code,Location Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
16- Item Ledger Entry Type,Location Code,Item Category,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
17- Item No.,Item Ledger Entry Type,Location Code,Variant Code,Global Dimension 1 Code,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
18- Created In Store No.,Entry No.
which key should apply to speed this process , becuase in this table many lines
thanks for help
IF ItemRec.GET(ItemNo) THEN BEGIN
RCPTLINE.RESET;
RCPTLINE.SETRANGE("No.",ItemRec."No.");
IF RCPTLINE.FIND('+') THEN
EXIT(RCPTLINE."Cost per Unit")
END ;
RCPTLINE = Value Entry Table , but it takes long time to get this price
1- Entry No.
2- Item Ledger Entry No.,Entry Type Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Cost Amount (Expected) (ACY),Cost Amount (Actual) (ACY),Cost Amount (Non-Invtbl.)(ACY),Purchase Amount (Actual),Purchase Amount (Expected)
3- Item Ledger Entry No.,Document No.
4- Item No.,Posting Date,Item Ledger Entry Type,Entry Type,Item Charge No.,Location Code,Variant Code Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Purchase Amount (Actual),Item Ledger Entry Quantity
5- Item No.,Posting Date,Item Ledger Entry Type,Entry Type,Item Charge No.,Location Code,Variant Code,Global Dimension 1 Code,Global Dimension 2 Code Invoiced Quantity,Sales Amount (Expected),Sales Amount (Actual),Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Non-Invtbl.),Purchase Amount (Actual)
6- Document No.,Posting Date
7- Item No.,Valuation Date,Location Code,Variant Code Cost Amount (Expected),Cost Amount (Actual),Cost Amount (Expected) (ACY),Cost Amount (Actual) (ACY),Item Ledger Entry Quantity
8- Source Type,Source No.,Item No.,Posting Date,Entry Type Discount Amount,Cost Amount (Non-Invtbl.),Cost Amount (Actual),Cost Amount (Expected),Sales Amount (Actual),Sales Amount (Expected),Invoiced Quantity
9- Item Charge No.,Inventory Posting Group,Item No.
10- Capacity Ledger Entry No.,Entry Type Cost Amount (Actual),Cost Amount (Actual) (ACY)
11- Prod. Order No.
12- Source Type,Source No.,Global Dimension 1 Code,Global Dimension 2 Code,Item No.,Posting Date Discount Amount,Cost Amount (Non-Invtbl.),Cost Amount (Actual),Cost Amount (Expected),Sales Amount (Actual),Sales Amount (Expected),Invoiced Quantity
13- Item Ledger Entry Type,Location Code,Product Group,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
14- Item Ledger Entry Type,Offer No.,Item No.,Variant Code Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
15- Item Ledger Entry Type,Salespers./Purch. Code,Location Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
16- Item Ledger Entry Type,Location Code,Item Category,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
17- Item No.,Item Ledger Entry Type,Location Code,Variant Code,Global Dimension 1 Code,Global Dimension 2 Code,Posting Date Invoiced Quantity,Sales Amount (Actual),Cost Amount (Actual)
18- Created In Store No.,Entry No.
which key should apply to speed this process , becuase in this table many lines
thanks for help
0
Comments
-
The Item table has a field called Last Direct Cost.
Just take that value, instead of searching for it.
Besides, the last value entry is not the last cost... the last value entry can be a rounding entry or anything. Definetely not always the last cost.0 -
Since you need only the last record, I would suggest you use findlast instead of find('+').
The item ledger entry table would be a better choice since it has a sum (flowfield) of all the costs of the last movement of the item, but as suggested, the last direct cost flowfield in the item table would be best.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