CALCFIELDS Amount(LCY) per posting group

Hi fellow developers,

I have a problem regarding using the calcfields function to calculate the amount (LCY) of cust. ledger entry for my report, when i retrieve the records with specific parameters then i get a 0 value of amount (LCY). i have tried to use the calcfield as directed in NAV but it seems not working. below is my code:

grec_CustLedgerEntry.RESET;
grec_CustLedgerEntry.SETRANGE(grec_CustLedgerEntry.“Customer Posting Group”,Code);
grec_CustLedgerEntry.SETRANGE(grec_CustLedgerEntry.“Posting Date”,gdt_StartDate,gdt_EndDate);
grec_CustLedgerEntry.CALCFIELDS(“Amount (LCY)”);
IF grec_CustLedgerEntry.FINDSET THEN BEGIN
REPEAT
gdec_PostAmtFrm[k] += grec_CustLedgerEntry.“Amount (LCY)”;

UNTIL grec_CustLedgerEntry.NEXT = 0
END;

I put the codes in the Customer posting group, Body - onPreSection()

Appreciate your reply on this problem.Thanks

Regards,

Richard

if u want to calculate the groupwise total, then in the properties there is feild called group total, go there and specify the amount feild there.

Thanks shailesh but you cannot use that function since amount (LCY) is not a field, amount (LCY ) is a flowfield and u can calculate the amount only by calcfields function…

Hi, Richard,

I would put the calcfields line inside the repeat loop. It needs to be calculated on each found record

Anna is correct, you have placed the CALCFIELDS before you have even retrieved any records from the database. You can’t expect it to calculate anything if it doesn’t have a record or data to calculate with.

Thanks anna that is what i did and calcfields works. :slight_smile: