In coding i have used a temporary record variable with the Purchase line and I'm transferring the records from purchase line to the temporary Purch table(specific records).now the temp Purch line contains the records like below example
Doc No. Line no. Qty
Doc 1 10000 10
Doc1 20000 12
Doc1 30000 15
Doc2 10000 5
Doc3 20000 10
now i want to sum the qty by line no. i.e 10000 15 ,20000 22, 30000 15 ,if the line no. is same i have to sum the qty irrespective of doc no.s .
i think you have at least 4 options order by elegance and style ascending:
1. google "Navision group by" there are tons of threads
2. if you have a table with the right key, use CALCSUM as Amol suggest
3. Create a SQL view that do the group by and then use NAV to show the output
4. use a nested loop to create another tempTable with the result of the group by (this is a dirty solution )
Something like that:
IF yourTempTable.FINDSET() THEN BEGIN
yourTempTabletmp.line := yourTempTable.line;
yourTempTabletmp.doc := yourTempTable.doc;
// sum qty
yourTempTabletmp.qty := yourTempTabletmp.qty + yourTempTable.qty;
UNTIL (yourTempTable.NEXT = 0);
// fill another table after each iteration
//delete processed lineNo and go next
UNTIL ( yourTempTable.ISEMPTY() )
MESSAGE('%1 %2 %3',yourTempTabletmp.doc,yourTempTabletmp.line,yourTempTabletmp.qty);
UNTIL (yourTempTabletmp.NEXT = 0 );
Hope this can give you some ideas how to move forward ...
What problem you are facing now ??
Don't forget to the post(s) that solved your problem
How to sum the qty if the line nos are same and doc nos are different.
SET Key on the required fields and do the grouping....
© 1995-2013 Dynamics User Group, all rights reserved.