Problem assigning purchase amount to decimal variable

ClydoClydo Member Posts: 3
Hi,

I was asked to write a Nav report showing the last purchase amount for each item no. and variant for a particular location.

To do this I have created a report on the Item Variant table.
I have two Global variables:
    ile - Record - Item Ledger Entry LastPurchaseAmount - Decimal

The C/AL code is:
Item Variant - OnAfterGetRecord()
ile.SETCURRENTKEY("Entry No.") ;
ile.SETFILTER("Item No.", "Item No.");
ile.SETFILTER("Variant Code", Code);
ile.SETFILTER("Location Code", 'stock');
ile.SETFILTER("Entry Type", 'Purchase');

IF ile.FINDLAST THEN  
  LastDirectCost := ile."Purchase Amount (Actual)"

The problem I'm having is LastDirectCost is always returns 0 when the report is run.
whilst debuging i notice that If I use the LastDirectCost to return entry no. i.e. LastDirectCost := ile."Entry No." the report will display the entry no. of the ILE record I'm interested in and if I check that entry no. in the ILE table there is a Purchase Amount (actual) with a proper (non zero) value. So there is no problem with my SETFILTERs.
The decimal places property for the textbox that displays LastPurchaseAmount in the section designer is <2:2>.
What am I missing here?

Cheers.

Answers

Sign In or Register to comment.