Hello,
I have a report based on a dataitem of type "Item".
In this report I set various variables and filters and at the end I have a variable of type record "Sales Invoice Line" filtered for various field dynamically setted.
I want to calculate some total as for example Quantity or Amount. How is that possible? "Sales Invoice Line" is not a dataitem but only a record variable.
Do I have to loop for each single line to add the values?
I am developing a very complex analysis report.
Thank you very much
0
Comments
have a look at the CALCSUMS function - it should solve a lot of your problems.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thanks
I think you're mixing this up with CALCFIELDS which is for flowfields.
See the example in the help
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thank you very much
This command works with Sumindexfields which are setup on the keys tab on the table you are using.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
On this table the only SumIndex keys that I see under Key windows are : Amount,Amount Including VAT
1) Can't I use CALCSUMS for sum Quantity field?
2) do I have to use primary key "Document No.,Line No." or can I use a secondary key as "Type,No.,Sell-to Customer No." to be able to use CALCSUMS?
3) to get the value calculated in your previous example:
"
"Cust. Ledger Entry".SETCURRENTKEY("Customer No.","Date");
"Cust. Ledger Entry".SETRANGE("Customer No.", 'AAA 1050');
"Cust. Ledger Entry".SETRANGE("Date", 010196D, 123196D);
"Cust. Ledger Entry".CALCSUMS("Amount");
"
I have to read the value "Cust. Ledger Entry".Amount where there is the total ?
Thank you
1) Yes you can use the Quantity field but you will have to add it to an index.
2) You can add the sumindexfield to any of the key - use the one which is best for you as this can have a performance implication (look at the sales line table 37 for an example)
3) The total is in the value of "Cust. Ledger Entry".Amount after the call to the command. If you are using the line values in a report then Currreport.CreateTotals is the way to go.
Hope this helps.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html