Return to the Printing Tips
QSPGETF and QSPPUTF APIs and commands
IBM Knowledgebase item 8011926 describes two APIs that are undocumented in the AS/400 manuals. The two APIs, Get Spooled File
(QSPGETF) and Put Spooled File (QSPPUTF), copy spool files to and restore them from physical files, respectively. The advantage of
QSPGETF and QSPPUTF over the well-documented Copy Spooled File command (CPYSPLF) is that the APIs are able to copy Advanced Function Printing
Data Stream (AFPDS) and Intelligent Printer Data Stream (IPDS) spool files, whereas CPYSPLF cannot.
You can call the QSPGETF and QSPPUTF APIs directly, or you can call them using command wrappers over the APIs.
a. Calling the APIs Directly.
The QSPGETF API call below saves spool file QPRINT to database file SPOOLDB in USER1LIB library, member MBR1, where the spool file number
is 1 and the spool file job is 010160/user1/dsp03:
CALL PGM(QSYS/QSPGETF) PARM('QPRINT ' 'SPOOLDB USER1LIB ' + 'DSP03 USER1 010160' X'0001' 'MBR1 ')The QSPPUTF API call below creates a spool file in USER1 output queue in QGPL library from the MBR1 member in the SPOOLDB database file:
CALL PGM(QSYS/QSPPUTF) PARM('SPOOLDB USER1LIB ' 'USER1 QGPL ' 'MBR1 ')b. Calling the APIs from command wrappers.
The two calls below correspond to the examples above, but these examples use the command calls instead of calls directly to the APIs:
GETSPLF FILE(QPRINT) TOFILE(USER1LIB/SPOOLDB) + JOB(010160/USER1/DSP03) SPLNBR(1) TOMBR(MBR1) PUTSPLF FROMFILE(USER1LIB/SPOOLDB) OUTQ(QGPL/USER1) + FROMMBR(MBR1)Although the QSPGETF and QSPPUTF APIs are included in every OS/400 release since V3R2, the commands are not included. Fortunately, you can obtain the compiled commands and the command source code from the Knowledgebase item, which can be found at http://as400service.ibm.com/8625680A007CA5C6/0/10AFE2F98C7F5FB9862565C2007D46A8?Open&Highlight=2,8011926
This item was adapted from IBM Knowledgebase item 8011926
[report a broken link by clicking here]