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

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

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: