Another Midsummer Nights Dream
When saving SPLFs to a physical file, it's important to remember that the maximum number of SPLFs that can be created by a JOB in V5R1M0 is 999,999, but a physical file can only accommodate 32,767 members. To keep things simple, I suggest that the QMAXSPLF system value be 32,767 or less--then it's possible that every SPLF for a JOB could be saved within its own physical file. The physical file referenced by the SAV* commands will be created should it not already exist, and it's possible to automatically delete a SPLF once it's been successfully saved. Additionally, the SAVUSRSPLF command allows a SPLF creation date range to be specified.
The RSTOUTQ, RSTUSRSPLF and RSTJOBSPLF commands will always restore SPLFs with the same JOBNAME and where possible the same USRPRF as the original SPLF. Should the USRPRF not be found or the USRPRF is a restricted USRPRF (QDBSHR, QDOC, QLPAUTO, QLPINSTALL, QRJE, QSECOFR, QSPL, QDFTOWN, QTSTRQS, and QSYS), the restored SPLF will be restored with the USRPRF of the user that executes the RST* command. The original SPLF number from the original job can also be maintained by specifying ORGSPLNBR(*YES). Both the RSTOUTQ and RSTUSRSPLF also permit a SPLF save date range to be specified.
The SAVSPLF and RSTSPLF commands can save and restore any SPLF, including those saved by SAVOUTQ, SAVUSRSPLF and SAVJOBSPLF. The RSTOUTQ, RSTUSRSPLF and RSTJOBSPLF commands have been designed to only restore those SPLFs that have been saved by their corresponding SAV* command. For example, while the RSTOUTQ command can restore any SPLF saved by the SAVSPLF command, it can't restore any SPLF from SAVUSRSPLF and/or SAVJOBSPLF. The SAVSPLF and RSTSPLF commands really don't need to be used unless somebody wants to write their own SPLF archiving system.
As these coding examples don't have RPG and/or COBOL programs, I haven't written any SPLF index record that would log when and where every SPLF had been saved. But writing an SPLF index record should be a very easy job for any programmer. Because no SPLF index record is written, the RST* commands need to create an outfile of the members contained within an SPLF archive physical file. This can take some time depending on how many members make up the SPLF archive physical file.
The real advantage of these commands is that internally they use the QSPGETF and QSPPUTF APIs rather then the well-documented CPYSPLF examples, which permits Advanced Function Printing Data Stream (AFPDS) and Intelligent Data Stream (IPDS) SPLF to be saved and restored, whereas CPYSPLF cannot.