Writing a set number of records per page in BI Publisher

Problem

You want to write a set number of records before forcing a page break. This is common in French business documents where you have a tear-off slip at the end of a report, but the section needs to be blank if there report spools over more than one page.

I've seen a number of posts on this, all suggesting a loop with a mod function, and a page break command when true. But only one notes that you can't actually call a page break in a loop, you need to call another sub template with the page break.

Solution.



1. Open your loop
<?for-each@section:G_INVOICE_LINES?> 

2. Close your loop
<?end for-each?>

3. You logic for forcing a page break. This needs to be just before your close loop. In my case I want to split every 4 lines.
<?if@inlines:position() mod 4 = 0?><?call:breaking?><?end if?>

4. Your sub-template. I had loads of room, but you could condense this. It needs to be declared outside of your loop. I happened to put mine directly afterwards.
<?template:breaking?>
<?split-by-page-break:?>
<?end template?>

Result


Page 1, after 4 records we have forced a page break, leaving the rest of the page blank.

Page 2, with the footer when we want it.

Acknowledgment

https://myoracleappsworld.wordpress.com/tag/split-by-page-break/

Comments