Reset Page Count (Page X of Y) in UBE

PageNosReports like Sales Order Print, Invoice Print, Purchase Order Print often have the requirement to print the Page Numbers inline with the Orders. For e.g. each order should have Page numbers starting from 1. It becomes even complex when you have to reset page numbers like Page X of Y (like Page 1 of 3, Page 2 of 3 and Page 3 of 3) where X is the concurrent page number and Y is the total page count for an order.

To Reset Page the number is easy, where you just have to call the B9800580-Set Report Page Number BSFN to reset to the page number you need. But when you need to show the Total pages for an order or so, this BSFN does not satisfy the requirement. The B9800580 uses the API – ubeReport_SetpageNumber. To reset the Y value (Total number of pages), use a different API called ubeReport_SetPageNumberEx :

ubeReport_SetPageNumberEx(lpBhvrCom, lpDS->nPageNumber, lpDS->nResetTotalPages);

Where nPageNumber: set the page number to any number you want
nResetTotalPages: 1: resets the total pages to 1, 0: leaves it alone

Following is how you achieve the requirement.

  1. Create Data structure D5598058:
    1. PAGN – Page Number
    2. PGNF – Page Number Report (pass only 1 or 0)
    3. SUPPS – Suppress Error Message
    4. DTAI – Error Message ID
  2. Create a Custom BSFN : B5598058 – Set Report Page Number Ex
    *  Variable declarations
    int         nPageNumber; //PAGN
    int         nResetTotalPages;  //PGNF
    * Main Processing
    jdeStrcpy (lpDS->szErrorMessageID, _J("    "));
    MathNumericToInt (&lpDS->mnPageNumber, &nPageNumber);
    MathNumericToInt (&lpDS->mnPageNumberReport, &nResetTotalPages);if ((nNumber < 0) || (nNumber > 9999) ||
    (!ubeReport_SetPageNumberEx (lpBhvrCom, nPageNumber, nResetTotalPages)))
    jdeStrcpy (lpDS->szErrorMessageID, _J(“0279”));
    * Function Clean Up
    if (lpDS->szErrorMessageID[0] != _J(‘ ‘))
    return (ER_ERROR);
    return (ER_SUCCESS);
  3. On the Level Break Header of Order Number, call the Custom BSFN to reset the Page Number.

Hope this helps many!

Leave a Reply

Your email address will not be published. Required fields are marked *