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
  • 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 fasion 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(*FIRST) on the command. For all other spooled files you must specify MERGE(*YES). Then, one final time you must call the command with the same information as the last spooled file and specify MERGE(*LAST). This will trigger the command to merge all spooled files in the group and create the resulting document.

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(*FIRST)

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)

SPL2STMF FILE(REPORT3) JOB(332340/BVSTONE/QPADEV0014) SPLNBR(1) FROM(*FIRST) TO(*LAST) TOSTMF(allreports.pdf) DIR('/myfiles/reports') MERGE(*LAST)

Notice that the last command is a duplicate of the previous, but *LAST is specified for the MERGE parameter. This last command is used to send information to the SPLTOOL command to finish processing and merge all the spooled files previously listed.


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.
Comments