Chapter 13 - Merging Spooled Files
With SPLTOOL you are able to merge two or more *SCS or *AFPDS (AFPTOOL Required for *AFPDS) spooled files into the PDF formats. Merging can be performed one of two ways. Each way is described below as well some important notes to remember when merging spooled files.
Merging Spooled Files using the "Batch" Commands
Merging Spooled Files Manually
Merging Spooled Files using the PDFCAT command.
Important Notes about Merging Spooled Files
Merging Spooled Files using the "Batch" Commands
The first method used to merge spooled files into one document is using the SPLTOOL "Batch" comands. These commands consist of the following:
Spooled File to Stream File Batch (SPL2STMFB)
Spooled File to Email Batch (SPL2EMAILB)
Spooled file to FTP Batch (SPL2FTPB)
The Batch commands will allow you to select and process one or more spooled files in one command. By default, each spooled file processed will be placed into it's own seperate file. Using the MERGE(*YES) parameter on any of these commands will instead copy all of the data into one resulting document.
When using the MERGE(*YES) option with the batch commands you must also specify the Only File Name (ONLYF) parameter as *YES, and then specify a file name on the File Name (FNAME) parameter.
An example of using the command to copy all spooled files in output queue REPORTS with a user data containing the value COPY to a PDF document named "/myfiles/reports/allreports.pdf" is as follows:
SPL2STMFB OUTQ(REPORTS) FILE(*ALL) USER(*ALL) JOB(*ALL) JOBNUM(*ALL) SPLNUM(*ALL) USRD(COPY) FRMT(*ALL) DIR('/myfiles/reports') EXT(PDF) ONLYF(*YES) FNAME (allreports) MERGE(*YES)
Merging Spooled Files Manually
It is also possible to merge two or more spooled files into one document manually using the normal single file processing comands. These commands are as follows:
Spooled File to Stream File (SPL2STMF)
Spooled File to Email (SPL2EMAIL)
Spooled File to FTP (SPL2FTP)
In order to merge spooled files manually in this fashion you must use the MERGE parameter specifying a specific value for the first, all other spooled files, and the last spooled fie in the group. All commands must be run sequentially in the same job and the order that the spooled files are merged will be the order that the spooled files are processed.
For the first spooled file, you must specify MERGE(*NO) to create the initial PDF file. For all other spooled files you must specify MERGE(*YES).
The following example will merge three spooled files into one PDF document named "/myfiles/reports/allreports.pdf":
SPL2STMF FILE(QPJOBLOG) JOB(290242/BVSTONE/QPADEV0014) SPLNBR(2) FROM(*FIRST) TO(*LAST) TOSTMF(allreports.pdf) DIR('/myfiles/reports') MERGE(*NO)
SPL2STMF FILE(REPORT2) JOB(290430/BVSTONE/QPADEV0014) SPLNBR(1) FROM(*FIRST) TO(*LAST) TOSTMF(allreports.pdf) DIR('/myfiles/reports') MERGE(*YES)
SPL2STMF FILE(REPORT3) JOB(332340/BVSTONE/QPADEV0014) SPLNBR(1) FROM(*FIRST) TO(*LAST) TOSTMF(allreports.pdf) DIR('/myfiles/reports') MERGE(*YES)
Merging PDF Files Using the PDFCAT Command
Finally, the PDFCAT (PDF Concatenate) command can be used to merge files already in the PDF format. You would simply create all the PDF files using SPL2STMF, then for each PDF call the PDFCAT command to merge them all into one.
SPL2STMF FILE(QPJOBLOG) JOB(290242/BVSTONE/QPADEV0014) SPLNBR(2) FROM(*FIRST) TO(*LAST) TOSTMF(allreports.pdf) DIR('/myfiles/reports')
SPL2STMF FILE(REPORT2) JOB(290430/BVSTONE/QPADEV0014) SPLNBR(1) FROM(*FIRST) TO(*LAST) TOSTMF(report2.pdf) DIR('/myfiles/reports')
SPL2STMF FILE(REPORT3) JOB(332340/BVSTONE/QPADEV0014) SPLNBR(1) FROM(*FIRST) TO(*LAST) TOSTMF(report3.pdf) DIR('/myfiles/reports')
PDFCAT PDF('/myfiles/reports/allreports.pdf') CATPDF('/myfiles/reports/report2.pdf')
PDFCAT PDF('/myfiles/reports/allreports.pdf') CATPDF('/myfiles/reports/report3.pdf')
Of course, you will need to do some cleanup with this process as well, removing report2.pdf and report3.pdf when you're sure everything has went as it should.
Important Notes about Merging Spooled Files
When merging spooled files it is important to remember the following items:
Each spooled file will be created with it's own attributes before merging to the final document. This means that you can merge different sized reports, or even landscape and portrait spooled files.
Merging is only valid when specifying the PDF format.
Both *SCS and *AFPDS spooled files can be merged when both SPLTOOL and AFPTOOL are installed.