get last purchase price

hhhhhhhqathhhhhhhqat 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

Comments

  • crisnicolascrisnicolas Member Posts: 177
    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.
  • SogSog Member Posts: 1,023
    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.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.