Another Report Question

Hi There, I have a report that has a group header that groups by product type, in the group footer I have arrays Total[1]Total[2] etcth code below is supposed to create a filter apply it and maintain seperate group totals but it doesn’t infact I am finding that no grouping appears at all let alone totals. FOR i := 1 TO 6 DO BEGIN StartDate := CALCDATE(STRSUBSTNO(’-%1M’,i),WORKDATE); “Sales Analysis”.SETRANGE(“Posting Date”,StartDate,WORKDATE); CurrReport.CREATETOTALS(Month[i]); END; What am I overlooking. Many Thanks

I guess this code should go in the PreDataItem trigger, i.e. before the Sales Analysis records are processed, not after. You would need to declare your arrays as global variables, of course. CREATETOTALS can be used “to maintain totals for a variable in the same way as totals are maintained for fields by using the TotalFields property.”

[quote from Navision C/SIDE Help]
Grouping is set up either through code (which is the difficult way), or, if possible, by putting fields in the GroupTotalFields. Two notes of caution: 1. despite its name, GroupTotalFields does not cause Totals to be kept; you always need to use TotalFields or CREATETOTALS to keep totals. 2. grouping requires an appropriate key to be in use; see Navision help for GroupTotalFields for more details. Hope this helps. Alastair

A couple of quick things: 1) You only need to do CreateTotals once (CurrReport.CREATETOTALS(Month) - usually, as Alastair said, on PreDataItem). 2) You need to assign a value to Month[i]

Ok I have place this code in the OnPreDataItem section as follows: FOR i := 1 TO 6 DO BEGIN StartDate := CALCDATE(STRSUBSTNO(’-%1M’,i),WORKDATE); “Sales Analysis”.SETRANGE(“Posting Date”,StartDate,WORKDATE); CurrReport.CREATETOTALS(Month[i]); END; I have then placed within the Group Footer the fields Month[1] Month[2] etc but I get no output plus the grouping that I was getting for each Item Group no longer functions. So instead of getting the following: Item Cat Code Qty Month 1 Month 2 etc ABC 4 9088 89999 DEF 55 8888 90900 I get 3 Nothing Nothing

Now that I think about it, I’m not sure I understand your report, or whether CREATETOTALS would make sense. Could you tell us what data items you have, and what (numeric) fields or variables you have in the sections - it’s the Quantity or Amount fields that I’m interested in, or whatever it is that you want to sum up in Month[i]. Thanks, Alastair

I am guessing here at what your trying to do, so lets try. OnPreDataItem() CurrReport.CREATETOTALS(Month); FOR i := 1 TO 6 DO StartDate[i] := CALCDATE(STRSUBSTNO('-%1M',i),WORKDATE); // You only need to calculate the StartDates once if StartDate // declared as an array OnAfterGetRecord() FOR i := 1 TO 6 DO BEGIN "Sales Analysis".SETRANGE("Posting Date",StartDate[i],WORKDATE); "Sales Analysis".CALCSUMS(Value); Month[i] := Month[i] + "Sales Analysis".Value; END;

Thanks Steve that makes a lot of sense, one final question is how can I group this data to primary key, for example the array’s Month[i] should be reported per item category so for example: CATEGORY A Month[1] Month[2] Month[3] B … … …

Hi You will need to go ito Sections and create a GroupFooter for the required Dataitem, then add code similar to this DataItem, Groupfooter(n) OnPreSection() CurrReport.SHOWOUTPUT := CurrReport.TOTALSCAUSEDBY = FIELDNO("Item Category Code"); On my previous posting Month[i] := Month[i] + “Sales Analysis”.Value; should read Month[i] := “Sales Analysis”.Value;[:I] because CurrReport.CREATETOTALS is being used for the totaling.