Grouping in reports in OnPreDataItem - is it possible?

Din
Member Posts: 6
Hi to all 
I have got a question, is there any possibility of grouping information in the report, without using GroupTotalfields property of the item. The case is, i have to get the report, which runs on the table Item, but with two different groupings. As i understand i can get them sorted as i wish with SETCURRENTKEY, but what then - searched for anything that could group them in the process - but nothing
Does anyon know, whether there is any function capable of that?
If not, then i most probably redesign the thing to work on two different Item's so that it chooses one with the suitable grouping, but still, it would be nice to know, whether there is a possibility.
Would be very glad to here from anyone knowing anything about the matter O:)

I have got a question, is there any possibility of grouping information in the report, without using GroupTotalfields property of the item. The case is, i have to get the report, which runs on the table Item, but with two different groupings. As i understand i can get them sorted as i wish with SETCURRENTKEY, but what then - searched for anything that could group them in the process - but nothing

Does anyon know, whether there is any function capable of that?
If not, then i most probably redesign the thing to work on two different Item's so that it chooses one with the suitable grouping, but still, it would be nice to know, whether there is a possibility.
Would be very glad to here from anyone knowing anything about the matter O:)
0
Comments
-
I didn't exactly understand what you want to reach.
But instead of using "GroupTotalfields", you can write your own coding to do the grouping.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
That's exactly the thing i would like to do - but don't know how. i am just a begginer, that's why the question. I know how can i sort, but have no idea how can i write the expression to group them. Do you know?? If you do i would be very glad \:D/ to hear.0
-
Well in order to be more precise, here is the part, that has been done so far :
grupperimine - option type
CASE grupperimine OF
grupperimine::PMAd:
item.SETCURRENTKEY("PMA1","PMA2");
HERE I NEED SOME CODE TO GROUP BY
grupperimine::"Tootja ja hankija":
item.SETCURRENTKEY("Vendor No.","Manufacturer Code","PMA1","PMA3","PMA2","Alkoholi %","Unit Volume")
END;
HERE I NEED SOME CODE TO GROUP BY
Is there any function to tell the navi to group by the fields of the currentkey?? I couldnot find any so far :oops:0 -
There's no any specific function as far as I know, u will have to do your own coding for that, I even have seen this thing in some reports, but unfortunately I cannot remember what exactly are those reports. Whenever I ll find it, I ll let you know 4 sure.
Roshan0 -
Many thanks, I ll be waiting pationately :P0
-
If I understand correctly what you want to do:
Start reading your records in a way that goes fast (correct SETCURRENTKEY and SETRANGE), and save the totals in a temptable (grouping by the fields of the SETCURRENTKEY or even grouping by other fields) . Then run your report on the temptable.//clean the temptables (property TempTable=Yes on the variable) tmpRecord1.RESET; tmpRecord1.DELETEALL(FALSE); tmpRecord2.RESET; tmpRecord2.DELETEALL(FALSE); tmpRecord3.RESET; tmpRecord3.DELETEALL(FALSE); //creating the temptable: recRecord.RESET; recRecord.SETCURRENTKEY(A,B,C); recRecord.SETRANGE(A,from,to); recRecord.SETRANGE(B,from,to); IF recRecord.FIND('-') THEN REPEAT // maintain a total per field X,Y,Z IF (tmpRecord3.X <> recRecord3.X) OR (tmpRecord3.Y <> recRecord3.Y) OR (tmpRecord3.Z <> recRecord3.Z) THEN BEGIN tmpRecord3.RESET; tmpRecord3.SETCURRENTKEY(X,Y,Z); tmpRecord3.SETRANGE(X,recRecord.X); tmpRecord3.SETRANGE(Y,recRecord.Y); tmpRecord3.SETRANGE(Z,recRecord.Z); IF NOT tmpRecord3.FIND('-') THEN BEGIN tmpRecord3 := recRecord; // with this, you have also a valid primary key for the temptable tmpRecord3.TotalField1 := 0; tmpRecord3.TotalField2 := 0; tmpRecord3.TotalField3 := 0; tmpRecord3.INSERT(FALSE); END; END; tmpRecord3.TotalField1 += recRecord.TotalField1; tmpRecord3.TotalField2 += recRecord.TotalField2; tmpRecord3.TotalField3 += recRecord.TotalField3; tmpRecord3.MODIFY(FALSE); // maintain a total per field X,Y IF (tmpRecord2.X <> recRecord2.X) OR (tmpRecord2.Y <> recRecord2.Y) THEN BEGIN tmpRecord2.RESET; tmpRecord2.SETCURRENTKEY(X,Y,Z); tmpRecord2.SETRANGE(X,recRecord.X); tmpRecord2.SETRANGE(Y,recRecord.Y); IF NOT tmpRecord2.FIND('-') THEN BEGIN tmpRecord2 := recRecord; // with this, you have also a valid primary key for the temptable tmpRecord2.TotalField1 := 0; tmpRecord2.TotalField2 := 0; tmpRecord2.TotalField3 := 0; tmpRecord2.INSERT(FALSE); END; END; tmpRecord2.TotalField1 += recRecord.TotalField1; tmpRecord2.TotalField2 += recRecord.TotalField2; tmpRecord2.TotalField3 += recRecord.TotalField3; tmpRecord2.MODIFY(FALSE); // maintain a total per field X IF (tmpRecord1.X <> recRecord2.X) THEN BEGIN tmpRecord1.RESET; tmpRecord1.SETCURRENTKEY(X,Y,Z); tmpRecord1.SETRANGE(X,recRecord.X); IF NOT tmpRecord1.FIND('-') THEN BEGIN tmpRecord1 := recRecord; // with this, you have also a valid primary key for the temptable tmpRecord1.TotalField1 := 0; tmpRecord1.TotalField2 := 0; tmpRecord1.TotalField3 := 0; tmpRecord1.INSERT(FALSE); END; END; tmpRecord1.TotalField1 += recRecord.TotalField1; tmpRecord1.TotalField2 += recRecord.TotalField2; tmpRecord1.TotalField3 += recRecord.TotalField3; tmpRecord1.MODIFY(FALSE); UNTIL recRecord.next = 0;
Now that you have a temptable with the totals, you can start your report on those temptables.
You need a dataitem on an integer per total-level (so 3 : X,Y,Z). Y must have property "DataItemIndent"=1 and Z property "DataItemIndent"=2
X - OnPreDataItem()tmpRecord1.RESET; tmpRecord1.SETCURRENTKEY(X,Y,Z); RESET; SETRANGE(Number,tmpRecord1.COUNT);
X - OnAfterGetRecord()IF Number = 1 THEN tmpRecord1.FIND('-') ELSE tmpRecord1.NEXT = 0;
Y - OnPreDataItem()tmpRecord2.RESET; tmpRecord2.SETCURRENTKEY(X,Y,Z); tmpRecord2.SETRANGE(X,tmpRecord1.X); RESET; SETRANGE(Number,tmpRecord2.COUNT);
Y - OnAfterGetRecord()IF Number = 1 THEN tmpRecord2.FIND('-') ELSE tmpRecord2.NEXT = 0;
Z - OnPreDataItem()tmpRecord3.RESET; tmpRecord3.SETCURRENTKEY(X,Y,Z); tmpRecord3.SETRANGE(X,tmpRecord2.X); tmpRecord3.SETRANGE(Y,tmpRecord2.Y); RESET; SETRANGE(Number,tmpRecord3.COUNT);
Z - OnAfterGetRecord()IF Number = 1 THEN tmpRecord3.FIND('-') ELSE tmpRecord3.NEXT = 0;
In the sections, you can use the values of the temptables in the sourceexpresion. Eg. tmpRecord3.Y or tmpRecord3.TotalField1.
And if you want the total TotalField1 for X or Y or Z, use tmpRecord1.TotalField1 or tmpRecord2.TotalField1 or tmpRecord3.TotalField1.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
sorry, for the delay. Thanks i will try it out
Seems like somthing, that would work ok under the circumstances.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions