Capturing SCS and AFP Spool Files to AS/400 Database File - Support

Capturing SCS and AFP Spool Files to AS/400 Database File

From Support

Jump to: navigation, search

IBM AS/400 Support Line Technical Document

Document Number: 8011926 ____________________________________________________________ Functional Area: Print SubFunctional Area: Data Collection/Traces SubSubFunctional Area: General ____________________________________________________________ Product: OS/400 PRINT/SPOOL (5769SS1SP); OS/400 PRINT/SPOOL (5716SS1SP); OS/400 PRINT/SPOOL (5763SS1SP) Release: ALL

Classification: Registered

Keywords: ____________________________________________________________ Document Title:Using QSPGETF and QSPPUTF APIs with Command Source Document Description:

This document covers usage of the QSPGETF and QSPPUTF print APIs. The command source for the QSPGETF API is supplied if the user wants to facility usage at a command entry screen. This is intended for archiving or AS/400 support diagnostics when the spoolfile printer device type is

  • AFPDS, *IPDS, or special controls in the spoolfile that does not allow the

CPYSPLF command to work.

These are the instructions to archive the spool file to a physical file. Use QSPPUTF to restore as a spoolfile.

Let the program create the file for you. If you have problems with it creating, then create before running the program.

Enter at the command line:

CRTPF  FILE(  )  RCDLEN(4083)  MAXMBRS(*NOMAX)  +
SIZE(*NOMAX)  LVLCHK(*NO)

Example usage of the QSPGETF API to write to a member in your database file:

CALL PGM(QSYS/QSPGETF) PARM('QPRINT    ' 'SPOOLDB   USER1LIB   ' 'DSP03 USER1     010160'   X'0001' 'MBR1      ')

This API call dumps a spool file QPRINT to a database file SPOOLDB in USER1LIB library, member MBR1. The spool file number is 1. The spool file job is 010160/user1/dsp03. This information can be seen in the WRKSPLF screen by pressing F11 or using Option 2.

The parameter values must be in uppercase and there must be a space between the single quotation marks.

Following are the parts to the parameter list:

 o     The 10-character spool file name.                                  
 o     A 20-character database file and library. Allow for 10             
       characters for each name.                                          
 o     A 26-character qualified job name for the spool file.  This name   
       can be seen in the WRKSPLF screen (press F11).  Allow 10           
       characters each for the job name and user, and 6 positions for     
       the job number.                                                    
 o     Numeric file number, 1 through 9999.  Use the hexadecimal          
       representation as in the example.  Make sure a space is inserted   
       after the previous single quotation mark and the X'0001'.          
 o     10 characters for the database member.                             
                                                                          

To restore the spool file from the database follow the example and instructions below.

Example usage of the QSPPUTF API to create a spoolfile from a member in your database file:

CALL  PGM(QSYS/QSPPUTF)  PARM('SPOOLDB  USER1LIB  '  'USER1      QGPL      '

'MBR1 ')

This API call creates a spool file in USER1 output queue in QGPL library from the MBR1 member in the SPOOLDB database file.

The parameter values must be in uppercase, and there must be a space between the quotes. Following are the parts to the parameter list:


 o     20-character database file and library.  Allow for 10  characters  
       for each name.                                                     
 o     20-character output queue name and library.  Allow for 10          
       characters for each name.                                          
 o     10 characters for the database member.                             

The above API programs can be run from the command line or from a CL program. If you are going to use these APIs on a regular basis, a command interface would be more convenient. The following is the command source for the QSPGETF API.

The source code for command GETSPLF, command interface to QSYS/QSPGETF follows. To compile the command, on the OS/400 command line type the following:

CRTCMD  CMD(lib_name/GETSPLF)  PGM(QSYS/QSPGETF)  +
SRCFILE(lib_name/file_name)  SRCMBR(*CMD)
         GETSPLF: 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) VARY(*NO) +
                   EXPR(*YES) PASSATR(*NO)
              QUAL TYPE(*NAME) LEN(10) RSTD(*NO) DFT(*LIBL) MIN(0) FULL(*NO) +
                   SPCVAL((*LIBL) (*CURLIB *CURLIB)) VARY(*NO) EXPR(*YES)+
                   PASSATR(*NO) PROMPT('Library')
         Q2:  QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(1) FULL(*NO) +
                   VARY(*NO) EXPR(*YES) PASSATR(*NO)
              QUAL TYPE(*NAME) LEN(10) RSTD(*NO) MIN(0) FULL(*NO) VARY(*NO) +
                   EXPR(*YES) PASSATR(*NO) PROMPT('User')
              QUAL TYPE(*CHAR) LEN(6) RSTD(*NO) RANGE(000000 999999) MIN(0) +
                   FULL(*YES) EXPR(*YES) PASSATR(*NO) PROMPT('Number')


The source code for command PUTSPLF, command interface to QSYS/QSPPUTF follows (see Note below). To compile the command, on the OS/400 command line type the following:

CRTCMD CMD(lib_name/PUTSPLF) PGM(QSYS/QSPPUTF) + SRCFILE(lib_name/file_name) SRCMBR(*CMD)

Note: The source is not included, Use the GETSPLF as an example.

Here’s the source that we setup.

/*********************************************************************/
/* COMMAND FROM IBM - CALLS API QSPPUTF                              */
/*   THIS COMMAND WILL COPY AN AFPDS OR IPDS DISK  FILE BACK TO A    */
/*   SPOOL FILE.  THE SPOOL FILE WILL BE QPRINT.                     */
/*   OF THE CONTROL CHARACTERS IN THE SPOOL FILE.                    */
/*   THIS COMMAND WILL RESTORE THE SPOOL FILE FROM A 4083 CHARACTER  */
/*   FILE.  USE THE GETSPLF COMMAND TO STORE TO A DISK FILE.         */
/*********************************************************************/
 PUTSPLF:    CMD        PROMPT('Put Back To Spooled File')

             PARM       KWD(TOFILE) TYPE(Q1) RTNVAL(*NO) MIN(1) +
                       MAX(1) FILE(*OUT) PROMPT('From data base file')

             PARM       KWD(OUTQ) TYPE(Q2) PROMPT('Spooled Output +
                          Queue Name:')
             PARM       KWD(FRMMBR) 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')

 Q2:         QUAL       TYPE(*NAME) LEN(10) DFT(*PRTFILE) +
                          SPCVAL((*PRTFILE)) EXPR(*YES)
             QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                         SPCVAL((*LIBL)) EXPR(*YES) +
                         PROMPT('Library Name:')
 
Personal tools