Options

Page of Pages - Solution

rkaufmannrkaufmann 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

Comments

  • Options
    RobertMoRobertMo Member Posts: 484
    Good idea, although it costs double running time.
    And you should delete the file in the end to clean up.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    OliverTOliverT Member Posts: 37
    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'); )
  • Options
    rkaufmannrkaufmann Member Posts: 71
    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.
  • Options
    RobertMoRobertMo Member Posts: 484
    This topic could be part of Tips and Tricks
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    aleix1979aleix1979 Member Posts: 213
    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 Developer
  • Options
    RobertMoRobertMo Member Posts: 484
    well the second run can be even faster, because some data can remain in buffers...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    PollekePolleke Member Posts: 18
    It is an idea but it does not take the printer characteristics into acount. The same report may apear different on two different printers.
  • Options
    rwabelrwabel Member Posts: 32
    thanks a lot for the solution. It works!
  • Options
    BagheeraBagheera Member Posts: 57
    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?
    animateduserbar6sx.gif
  • Options
    vutrunghieuvutrunghieu Member Posts: 3
    could you explain me what functions DefTotalPages(PageCount) does?
  • Options
    xmhwbxmhwb Member Posts: 1
    But where to write these code
    "TestReport.SaveAsHtml....."
  • Options
    jmjm Member Posts: 156
    br
    Josef Metz
  • Options
    feilongfeilong Member Posts: 6
    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 lot
  • Options
    Cem_KaraerCem_Karaer Member Posts: 281
    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 2005
  • Options
    rickbmanrickbman Member Posts: 1
    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.
  • Options
    andy76andy76 Member Posts: 616
    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 you
  • Options
    [TweaK][TweaK] Member Posts: 14
    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 concerned
  • Options
    gvolkovgvolkov Member Posts: 196
    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.com
  • Options
    [TweaK][TweaK] Member Posts: 14
    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?
Sign In or Register to comment.