TechTip: Saving Spool Files to Disk--An Alternate Method for V4R5

IBM i (OS/400, i5/OS)
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
I have a method for saving spool files to disk that can handle all files, not just *SCS files. In the current era, when graphical files are growing in importance, this might be a good solution for some shops. I use the undocumented IBM APIs named QSPGETF and QSPPUTF. These create mirror images of the spool file data files in flat files with a record length of 4083.

Below is the source code for GETSF and PUTSF. GETSF calls program QSPGETF in QSYS, while command PUTSF calls program QSPPUTF in QSYS. GETSF transfers the spool file into a physical file. You have to build the physical file first as a 4083 byte file with level checking turned off. Use Create Physical File (CRTPF) to build the file:

CRTPF FILE(mylib/myfile) RCDLEN(4083) LVLCHK(*NO)

NOTE: These commands work fine on a V4R5 system, but there is a problem under V5R1. Under V5R1, the spool number is a six-digit number, so the command must be modified accordingly.

--Rich Loeber
Kisco Information Systems

The code:

/*====================================================*/
/* To compile:                                        */
/*                                                    */
/*  CRTCMD     CMD(XXX/GETSF) PGM(QSYS/QSPGETF) +     */
/*                        SRCFILE(XXX/QCMDSRC)        */
/*                                                    */
/*====================================================*/
GETSF: +
    CMD  PROMPT('Get Spooled File')
    PARM KWD(FILE) TYPE(*NAME) LEN(10) RTNVAL(*NO) +
           RSTD(*NO) MIN(1) MAX(1) FILE(*IN) +
           FULL(*NO) EXPR(*YES) VARY(*NO) +
           PASSATR(*NO) PROMPT('SPOOLED FILE')
    PARM KWD(TOFILE) TYPE(Q1) RTNVAL(*NO) MIN(1) +
           MAX(1) FILE(*OUT) PROMPT('TO DATA BASE FILE')
    PARM KWD(JOB) TYPE(Q2) RTNVAL(*NO) DFT(*) +
           SNGVAL((*)) MIN(0) MAX(1) FILE(*NO) +
           PROMPT('JOB NAME')
    PARM KWD(SPLNBR) TYPE(*INT2) RTNVAL(*NO) +
           RSTD(*NO) DFT(*ONLY) RANGE(1 9999) +
           SPCVAL((*ONLY 0) (*LAST -1)) MIN(0) +
           MAX(1) EXPR(*YES) VARY(*NO) PASSATR(*NO) +
           PROMPT('SPOOLED FILE NUMBER')
    PARM KWD(TOMBR) TYPE(*NAME) LEN(10) RTNVAL(*NO) +
           RSTD(*NO) DFT(*FIRST) SPCVAL((*FIRST)) +
           MIN(0) MAX(1) FILE(*NO) FULL(*NO) +
           EXPR(*YES) VARY(*NO) PASSATR(*NO) +
           PROMPT('TO MEMBER')
Q1: QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(1) +
           FULL(*NO) EXPR(*YES) VARY(*NO) PASSATR(*NO)
    QUAL TYPE(*NAME) LEN(10) RSTD(*NO) DFT(*LIBL) +
            SPCVAL((*LIBL) (*CURLIB *CURLIB)) MIN(0) +
           FULL(*NO) EXPR(*YES) VARY(*NO) +
           PASSATR(*NO) PROMPT('LIBRARY')
Q2: QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(1) +
           FULL(*NO) EXPR(*YES) VARY(*NO) PASSATR(*NO)
    QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(0) +
           FULL(*NO) EXPR(*YES) VARY(*NO) +
           PASSATR(*NO) PROMPT('USER')
    QUAL TYPE(*CHAR) LEN(6) RSTD(*NO) RANGE(000000 +
           999999) MIN(0) FULL(*YES) EXPR(*YES) +
           PASSATR(*NO) PROMPT('NUMBER')


/*====================================================*/
/* To compile:                                        */
/*                                                    */
/*  CRTCMD     CMD(XXX/PUTSF) PGM(QSYS/QSPPUTF) +     */
/*                        SRCFILE(XXX/QCMDSRC)        */
/*                                                    */
/*====================================================*/
PUTSPLF: +
    CMD  PROMPT('PUT SPOOLED FILE')
    PARM KWD(FROMFILE) TYPE(Q1) RTNVAL(*NO) MIN(1) +
           MAX(1) FILE(*OUT) PROMPT('FROM FILE')
    PARM KWD(OUTQ) TYPE(Q1) RTNVAL(*NO) MIN(1) +
           MAX(1) FILE(*OUT) PROMPT('OUTPUT QUEUE')
    PARM KWD(FROMMBR) TYPE(*NAME) LEN(10) RTNVAL(*NO) +
           RSTD(*NO) DFT(*FIRST) SPCVAL((*FIRST)) +
           MIN(0) MAX(1) FILE(*NO) FULL(*NO) +
           EXPR(*YES) VARY(*NO) PASSATR(*NO) +
           PROMPT('FROM MEMBER')
Q1: QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(1) +
           FULL(*NO) EXPR(*YES) VARY(*NO) PASSATR(*NO)
    QUAL TYPE(*NAME) LEN(10) RSTD(*NO) DFT(*LIBL) +
           SPCVAL((*LIBL) (*CURLIB *CURLIB)) MIN(0) +
           FULL(*NO) EXPR(*YES) VARY(*NO) +
           PASSATR(*NO) PROMPT('LIBRARY')



BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$