IForms Multiple Form Overlay Template Example
From Support
Contents |
iForms Multiple Overlay Example Overview
This iForms example is an example of a spool file document where each page of the form document can have a different overlay (subreport) based on a value found within the report. This example checks for values in the $F{BillTo} field and determines the overlay to use for rendering the selected page.
Download Link
Listed below is the download for our new iForms sample multiple invoice overlay: http://downloads.rjssoftware.com/files/rjsiforms/templates/invoicemultioverlay.exe
Unzip these to C:\RJSIFORMS and copy all of the files to the /RJSIFORMS folder on your iSeries.
List of iForms Template files
invoicemultimain.jrxml invoicemultimain.jasper invoicemultimain.rjsxml invoicemultisubreport1.jrxml invoicemultisubreport1.jasper invoicemultisubreport2.jrxml invoicemultisubreport2.jasper invoicemultisubreport3.jrxml invoicemultisubreport3.jasper invoicemultisubreport4.jrxml invoicemultisubreport4.jasper invoicemultimainScriptlet.java invoicemultimainScriptlet.class
How the example works
There is a main form which you will run via the SPLIFORM command called: invoicemultimain.jrxml. This form's sole job is to read each page of the spool file work file we create with SPLIFORM and then call out to a Java Scriptlet function (located in invoicemultimainScriptlet.java) called getSubReport(stringvalue) to determine which subreport to be used for each page to be rendered based on the info in the $F{BILLTO} field. Then it calls the appropriate subreport based on the result of the getSubReport call. Each subreport prints the current page from the extracted spool file.
- Note: if you make changes in invoicemultimainScriptlet.java, they must be manually compiled before running on the iSeries command line:
Run the SPLIFORM command once against any form. This will set your Java classpath for iForms. Type: STRQSH and press Enter. Type: cd /rjsiforms and press Enter. Type: javac invoicemultimainScriptlet.java and press Enter to recompile the scriptlet. Type: ls /rjsiforms/invoicemultimainScriptlet.class to see if the class was recompiled.
There are 4 sample subreports that each print the data for the current page number passed to it from invoicemultimain.jrxml. They are named invoicemultisubreport1.jrxml - invoicemultisubreport4.jrxml
For my example each subreport is exactly the same and the query for each one takes in the REPORTSQL parm and PAGENUMBER field value for current page from invoicemultimain.jrxml. The only difference between the 4 subreports is the word INVOICE changes colors. In real practice, each subreport can have VERY different processing if needed.
How to run the sample
1.) GO RJSIFORMS, take option 50 and then option 20. Generate Sample INVOICE spool file in RJSIFORMS output queue
2.) Run the following command to generate the sample PDF file:
SPLIFORM FILE(INVOICE)
JOB(*)
TEMPLATE('/rjsiforms/invoicemultimain.jrxml')
XMLDEFFILE('/rjsiforms/invoicemultimain.rjsxml')
OUTPUTFILE('/rjsiforms/invoicemulti.pdf')
DSPSTDOUT(*NO)
- Notice that when you view /rjsiforms/invoicemulti.pdf, the word INVOICE should be Red on pages 1/2, Blue on 3/4 and Green on 5. If Cyan shows that means the default overlay was chosen for some reason.
