Page of Pages - Solution
rkaufmann
Member Posts: 71
Hi,
I just had a conversation with the MBS-Support, according to the problem to have something like "page# of totalpages" on a report.
The person I was talking had a good idea, and for me this works.
Here's the Code-Sample:
// BEGIN of Sample
CLEAR(TestReport);
TestReport.SAVEASHTML('c:\test.html');
// Call a function in the report that returns
// "CURRREPORT.PAGENO" after the SAVEASHTML has finished
PageCount := TestReport.ReturnTotalPages;
CLEAR(TestReport);
// Call a function in the report an use the PageCount
// as Parameter
TestReport.DefTotalPages(PageCount);
TestReport.RUN;
// END of Sample
"TestReport" is a Variable of type Report.
"PageCount" is a Variable of type Integer
Hope this helps.
Bye,
Rolf
I just had a conversation with the MBS-Support, according to the problem to have something like "page# of totalpages" on a report.
The person I was talking had a good idea, and for me this works.
Here's the Code-Sample:
// BEGIN of Sample
CLEAR(TestReport);
TestReport.SAVEASHTML('c:\test.html');
// Call a function in the report that returns
// "CURRREPORT.PAGENO" after the SAVEASHTML has finished
PageCount := TestReport.ReturnTotalPages;
CLEAR(TestReport);
// Call a function in the report an use the PageCount
// as Parameter
TestReport.DefTotalPages(PageCount);
TestReport.RUN;
// END of Sample
"TestReport" is a Variable of type Report.
"PageCount" is a Variable of type Integer
Hope this helps.
Bye,
Rolf
0
Comments
-
Good idea, although it costs double running time.
And you should delete the file in the end to clean up.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
i also thought about a solution like this ... but i was scarred by the long runtime (twice as 'normal'
)
but if you do so you also should save the file in the temp-directory of the pc (for this use ENVIRON('TEMP'); )0 -
I know it will take the double running time.
The Code should only be a sample, it is not "clean" code.
But this solution is the only way, to get the exact total number of pages (official statement of Navision-Support).
To count the records that will be printed an than calculate the number of pages that will be used, only work for simple list-style reports.0 -
This topic could be part of Tips and Tricks®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
It's an stunning idea for an old issue. But, is it possible to delete repotely the same file? Above all you don't want your company's reports to be left on the local net.
And about the time: does it cost the same to print in Navision rather than to html? We use hand-made reports for inventory because in some branches of my company the Inventory Valuation takes more than a work-time day.Navision Developer0 -
well the second run can be even faster, because some data can remain in buffers...®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
It is an idea but it does not take the printer characteristics into acount. The same report may apear different on two different printers.0
-
thanks a lot for the solution. It works!0
-
This implementation has issues in counting the pages properly. Report might be one page and it counts two, or the other way around...
Anyone can figure out why?
0 -
could you explain me what functions DefTotalPages(PageCount) does?0
-
But where to write these code
"TestReport.SaveAsHtml....."0 -
-
dear all,
I can run the solution and saveashtml in Form object. But how can i use saveashtml in report. For example, when i run Purchase Order report, i cant use currReport.saveashtml. The common demand show the total page when preview the report and we need to put the saveashtml function in report trigger. Can anyone give a example.
I tried on the triggers of a report, but cant work ](*,)
Thanks a lot0 -
SaveAsHtml command can only be used with a report variable or as a method of the REPORT. So you cannot use it inside the report itself.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
Ok, I'm fairly new to Navision but I have tried to solve this problem in other database systems and I know it is a pain in the neck. Reading the code I think I understand the logic of it, however being new to Navision I am not exactly sure where to put the code. Do I put it in the CAL code for the entire report or the CAL Code for an indivual section.
I'm actually tring to rework this so that I can have a different footer print on the last page than on all the other pages. I figured I would use the code listed in here and then in each of those footer sections I would have code similar to this:IF CurrReport.PAGENO := TestReport.PageCount THEN BEGIN // Last Page END;
I'm just not sure where to put the code this part of the code:// BEGIN of Sample CLEAR(TestReport); TestReport.SAVEASHTML('c:\test.html'); // Call a function in the report that returns // "CURRREPORT.PAGENO" after the SAVEASHTML has finished PageCount := TestReport.ReturnTotalPages; CLEAR(TestReport); // Call a function in the report an use the PageCount // as Parameter TestReport.DefTotalPages(PageCount); TestReport.RUN; // END of Sample
Now it could be that I am doing this completely wrong, but as I said I am new to this navision thing.0 -
Is the first post, the only method?
Do I have to create a new report only with this code to be able to run the other report (variable TestReport) or a new codeunit?
In some Navision standard code/report there is not an example of how they do?
Thank you0 -
Bagheera wrote:This implementation has issues in counting the pages properly. Report might be one page and it counts two, or the other way around...
Anyone can figure out why?
I agree with "Bagheera"..
I have fully implemented this method into some reports wich have been testrunning for quite some time now.
The counting of the pages indeed DOES NOT add up properly.. it might be too low, or too high, or just right ...
The reason for this is still unclear to me.. also, it makes no difference wether you use the SAVEASHMTL or SAVEASXML..
It's the same sheisse.. unfortunatly :'(
So does anyone know why the page count doesn't always add up properly?
If not.. Then NO, THIS IS NOT A RELIABLE SOLUTION for asfar as i'm concerned0 -
I have done that like three years ago. THis was posted in some topic here. Works great, but double processing time. Another way to do it, is to count page height. (calculate number of records for output) times your estimated space its going to take up on the page... and you get the idea. Much more complicated, but in terms of processing, much faster. I can probably dig up a sample.Microsoft Certified Technology Specialist
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com0 -
The reason why the "SAVEASHTML" PageCount works for 1 person but not for some others seems to be the real issue.
Imo: thats what we really need to know, why does the PageCount not add up for some people, but then for others it does..
What is the Variable that makes the pagecount differ for some people?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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

