Print the Total Page Number

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2009-02-27 in Download section
Print the Total Page Number
small trick to print the total page number

This fob file is uploaded as support for the thread Display page no in format PageNo / TotalPage Simple trick.
Objects are Form 80000 & Report 80000.

http://www.mibuso.com/dlinfo.asp?FileID=962

Discuss this download here.

Comments

  • MtamimiiMtamimii Member Posts: 7
    OBJECT Form 80000 GetPageNoTest
    {
      OBJECT-PROPERTIES
      {
        Date=05/31/08;
        Time=[ 8:27:29 AM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=8000;
        Height=3190;
      }
      CONTROLS
      {
        { 1000000000;CommandButton;1980;1210;2860;550;
                                                     CaptionML=ENU=Run Vendor Report;
                                                     OnPush=BEGIN
                                                              {
                                                              intFileName := 0;
    
                                                              REPEAT
                                                                 intFileName := intFileName + 1
                                                              UNTIL NOT EXISTS ( FORMAT(intFileName) + '.xml');
    
                                                              CLEAR(rptTestReport);
    
                                                              rptTestReport.SAVEASXML(FORMAT(intFileName) + '.xml');
    
                                                              intTotalPageNo :=rptTestReport.getPageNo;
    
                                                              IF ERASE( FORMAT(intFileName) + '.xml') THEN BEGIN
                                                              END;
    
                                                              CLEAR(rptTestReport);
    
                                                              rptTestReport.SetPageNo (intTotalPageNo);
                                                              }
                                                              rptTestReport.RUN;
    
                                                              CLEAR(rptTestReport);
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          rptTestReport@1000000000 : Report 80000;
          intTotalPageNo@1000000001 : Integer;
          intFileName@1000000002 : Integer;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Report 80000 GetPageNoForOrder
    {
      OBJECT-PROPERTIES
      {
        Date=05/31/08;
        Time=[ 8:54:00 AM];
        Modified=Yes;
        Version List=NAVW15.00;
      }
      PROPERTIES
      {
        CaptionML=ENU=Vendor - List;
        OnPreReport=BEGIN
    
                      VendFilter := Vendor.GETFILTERS;
    
                      IF NOT bolCalcPageNo  THEN BEGIN
                         intFileName := 0;
    
                         REPEAT
                         intFileName := intFileName + 1
                         UNTIL NOT EXISTS ( FORMAT(intFileName) + '.xml');
    
                         CLEAR(rptTestReport);
                         rptTestReport.SetCalcStatus;
                         rptTestReport.SETTABLEVIEW (Vendor);
                         rptTestReport.SAVEASXML(FORMAT(intFileName) + '.xml');
    
                         intTotalPageNo :=rptTestReport.getPageNo;
    
                         IF ERASE( FORMAT(intFileName) + '.xml') THEN BEGIN
                         END;
                      END;
                    END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table23;
            OnPreDataItem=BEGIN
    
    
    
                            CurrReport.CREATETOTALS("Balance (LCY)");
                          END;
    
            OnAfterGetRecord=BEGIN
                               CALCFIELDS("Balance (LCY)");
                               FormatAddr.FormatAddr(
                                 VendAddr,Name,"Name 2",'',Address,"Address 2",
                                 City,"Post Code",County,"Country/Region Code");
                             END;
    
            ReqFilterFields=No.,Search Name,Vendor Posting Group;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1004;
              }
              CONTROLS
              {
                { 1   ;Label        ;0    ;0    ;7500 ;423  ;FontSize=8;
                                                             FontBold=Yes;
                                                             CaptionML=ENU=Vendor - List }
                { 2   ;TextBox      ;15000;0    ;3150 ;423  ;HorzAlign=Right;
                                                             SourceExpr=FORMAT(TODAY,0,4) }
                { 3   ;TextBox      ;0    ;423  ;7500 ;423  ;SourceExpr=COMPANYNAME }
                { 1000000000;Label  ;15928;450  ;750  ;423  ;ParentControl=1000000001 }
                { 1000000001;TextBox;16678;450  ;450  ;423  ;CaptionML=ENU=Page;
                                                             SourceExpr=CurrReport.PAGENO }
                { 1000000002;Label  ;17128;451  ;485  ;423  ;HorzAlign=Center;
                                                             VertAlign=Center;
                                                             CaptionML=ENU=/ }
                { 1000000003;TextBox;17604;451  ;450  ;423  ;CaptionML=ENU=Page;
                                                             SourceExpr=rptTestReport.getPageNo }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
              }
              CONTROLS
              {
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=450;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (VendFilter <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 8   ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr=Vendor.TABLECAPTION + ': ' + VendFilter }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1269;
              }
              CONTROLS
              {
                { 9   ;Label        ;0    ;0    ;1500 ;846  ;ParentControl=18;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 10  ;Label        ;1650 ;0    ;4500 ;846  ;ParentControl=19;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 11  ;Label        ;6300 ;0    ;1500 ;846  ;ParentControl=20;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 12  ;Label        ;7950 ;0    ;1500 ;846  ;ParentControl=21;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 13  ;Label        ;9600 ;0    ;1500 ;846  ;ParentControl=22;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 14  ;Label        ;11250;0    ;1500 ;846  ;ParentControl=23;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 15  ;Label        ;12900;0    ;1500 ;846  ;ParentControl=24;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 16  ;Label        ;14550;0    ;750  ;846  ;ParentControl=25;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 17  ;Label        ;15450;0    ;1800 ;846  ;ParentControl=26;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
              }
               }
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18150;
                SectionHeight=4653;
              }
              CONTROLS
              {
                { 18  ;TextBox      ;0    ;0    ;1500 ;423  ;FontBold=Yes;
                                                             SourceExpr="No." }
                { 19  ;TextBox      ;1650 ;0    ;4500 ;423  ;FontBold=Yes;
                                                             CaptionML=ENU=Name and Address;
                                                             SourceExpr=VendAddr[1] }
                { 20  ;TextBox      ;6300 ;0    ;1500 ;423  ;CaptionML=ENU=Vendor Posting Group;
                                                             SourceExpr="Vendor Posting Group" }
                { 21  ;TextBox      ;7950 ;0    ;1500 ;423  ;CaptionML=ENU=Invoice Disc. Code;
                                                             SourceExpr="Invoice Disc. Code" }
                { 22  ;TextBox      ;9600 ;0    ;1500 ;423  ;CaptionML=ENU=Payment Terms Code;
                                                             SourceExpr="Payment Terms Code" }
                { 23  ;TextBox      ;11250;0    ;1500 ;423  ;CaptionML=ENU=Payment Method;
                                                             SourceExpr="Payment Method Code" }
                { 24  ;TextBox      ;12900;0    ;1500 ;423  ;SourceExpr=Priority }
                { 25  ;TextBox      ;14550;0    ;750  ;423  ;CaptionML=ENU=Currency Code;
                                                             SourceExpr="Currency Code" }
                { 26  ;TextBox      ;15450;0    ;1800 ;423  ;SourceExpr="Balance (LCY)" }
                { 27  ;TextBox      ;1650 ;423  ;4500 ;423  ;SourceExpr=VendAddr[2] }
                { 28  ;TextBox      ;1650 ;846  ;4500 ;423  ;SourceExpr=VendAddr[3] }
                { 29  ;TextBox      ;1650 ;1269 ;4500 ;423  ;SourceExpr=VendAddr[4] }
                { 30  ;TextBox      ;1650 ;1692 ;4500 ;423  ;SourceExpr=VendAddr[5] }
                { 31  ;Label        ;1650 ;2961 ;1500 ;423  ;ParentControl=32 }
                { 32  ;TextBox      ;3300 ;2961 ;2850 ;423  ;SourceExpr=Contact }
                { 33  ;Label        ;1650 ;3384 ;1500 ;423  ;ParentControl=34 }
                { 34  ;TextBox      ;3300 ;3384 ;2850 ;423  ;SourceExpr="Phone No." }
                { 37  ;TextBox      ;1650 ;2115 ;4500 ;423  ;SourceExpr=VendAddr[6] }
                { 38  ;TextBox      ;1650 ;2538 ;4500 ;423  ;SourceExpr=VendAddr[7] }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=476;
                OnPostSection=BEGIN
    
                                ReportTotalPage := CurrReport.PAGENO;
                              END;
    
              }
              CONTROLS
              {
                { 35  ;Label        ;0    ;0    ;2250 ;423  ;FontBold=Yes;
                                                             CaptionML=ENU=Total (LCY) }
                { 36  ;TextBox      ;2300 ;0    ;1800 ;423  ;FontBold=Yes;
                                                             SourceExpr="Balance (LCY)" }
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=0;
          Height=110;
          SaveValues=Yes;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          VendFilter@1000 : Text[250];
          VendAddr@1001 : ARRAY [8] OF Text[50];
          FormatAddr@1002 : Codeunit 365;
          ReportTotalPage@1000000000 : Integer;
          rptTestReport@1000000003 : Report 80000;
          intTotalPageNo@1000000002 : Integer;
          intFileName@1000000001 : Integer;
          bolCalcPageNo@1000000004 : Boolean;
    
        PROCEDURE getPageNo@1000000002() ReturnPage : Integer;
        BEGIN
          ReturnPage :=   ReportTotalPage;
        END;
    
        PROCEDURE SetPageNo@1000000032(PageNumber@1000000000 : Integer);
        BEGIN
           ReportTotalPage := PageNumber;
        END;
    
        PROCEDURE SetCalcStatus@1000000000();
        BEGIN
                 bolCalcPageNo := TRUE;
        END;
    
        BEGIN
        END.
      }
    }
    
    
  • podollypodolly Member Posts: 84
    I tried to apply this code into the printed purchase order, but find that the button on form called the codeunit, which will execute the report internally.

    Is there any suggestion how to include the code for generating the XML in the PO?

    Thanks.
  • Cem_KaraerCem_Karaer Member Posts: 281
    If you will use this method inside the same report, namely recursively, you must set a flag to prevent an endless loop. I used the fragment of the code in the OnPreReport section but created endless recursive report creations. So I set a flag, say SavingAsXML by using a function like below:
    SetSavingAsXML(aSavingAsXML : Boolean)
    SavingAsXML := aSavingAsXML;
    
    And write the following code like below:
    Report - OnPreReport()
    IF NOT SavingAsXML THEN
    BEGIN
      FileName := STRSUBSTNO('Temp_%1_Nakl.xml',FORMAT(CREATEDATETIME(TODAY,TIME),0,'<Day,2><Month,2><Year4><Hour><Minute><Second>'));
      CLEAR(RptNakledilenFis);
      GLEntry.COPYFILTERS("G/L Entry");
    
      RptNakledilenFis.SETTABLEVIEW(GLEntry);
      RptNakledilenFis.SetSavingAsXML(TRUE);
    
      IF ERASE(FileName) THEN;
      IF RptNakledilenFis.SAVEASXML(FileName) THEN;
    
      TotalPageNo := RptNakledilenFis.GetTotalPageNo;
    
      IF ERASE(FileName) THEN;
    END;
    
    RptNakledilenFis is a report variable that OnPreReport section belongs to.
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
Sign In or Register to comment.