Forum Stats

  • 3,837,237 Users
  • 2,262,240 Discussions
  • 7,900,230 Comments

Discussions

how to use page number info in format triggers

SiatGesi
SiatGesi Member Posts: 60 Bronze Badge

I wish to show/hide some labels/fields depending on if current page is the last one in report (for example, show SUBTOTAL label from 1 to n-1 pages, and TOTAL label in last page).

as an example, I wish to get something like this

FUNCTION SUBTOTALFORMATTRIGGER RETURN BOOLEAN IS

BEGIN

IF :TOTAL_REP_PAGES = 1 THEN

RETURN (FALSE);

ELSE

IF :CURRENT_PAGE_NUM = :TOTAL_REP_PAGES THEN

RETURN (FALSE);

ELSE

RETURN (TRUE);

END IF;

END IF;

END;


I was able to place two fields in report, showing the current page number and the total pages number (Source: page number/total pages). They works at runtime, but I cant get to use them in triggers (error ":TOTAL_REP_PAGES" is not defined).

I also tried to use SRW.GET_VALUE('TOTAL_REP_PAGES'), but I get an error message at runtime REP-1440: an unknown column name was passed to SRW.GET_VALUE in program unit SUBTOTALFORMATTRIGGER.

How can I use page number values in triggers?

Answers

  • Suresh Sangaran-Oracle
    Suresh Sangaran-Oracle Member Posts: 313 Employee

    Hello,

    Try this steps.

    1. Create the following package specification called "helper" in the report which contains a global variable called totalPages:

      PACKAGE helper IS
        totalPages NUMBER(2);
      END;
    

    2. In the layout editor, create a format trigger for the top most frame in the body of the Main Section (due to performance reasons, choose a group frame if possible).It is important that the object with the format trigger prints on the last report page (this is true for top most group frame).

    Alternate Approach: If the report has a Trailer Section, create the format trigger for the object in the Trailer Section instead of the Main Section since the trailer page(s) will contribute to the overall total of pages accumulated.

    3. The format trigger user code within the BEGIN/END block will consist of one

    statement as follows:

      SRW.GET_PAGE_NUM(helper.totalPages);
    

    4. Refer to helper.totalPages variable for total number of report pages from

    After Report trigger, e.g.:

      srw.message(0,'Total # of pages:'||to_char(helper.totalPages));
    
  • SiatGesi
    SiatGesi Member Posts: 60 Bronze Badge

    hello,

    I tried what you suggested, unsuccessfully.

    global variable totalPages is updated, but I need to know the total amount of pages while report is formatted.

    Reports Builder has a in-built parameter containing total amount of pages, so I can bind it into a field and use it in every page (look at F_TOT_PAGES field in below picture)



    I placed field F_TOT_PAGES in a repeating frame, and it is correctly shown at every page (it always contains the total amount of report pages).

    conversely, the helper.totalPages variable is updated at every page, so it would be unuseful for my purposes.

    Is it possible to use F_TOTAL_PAGES field value in PL/SQL triggers?

  • Hello,

    Normally the "Total Number Of Pages" value will not get determined until the whole report is formatted. So there is no way to know the total number of pages without running the report, unless you know beforehand how many records are printed per page.

    Regards,

    Dan