Create Spool File List

CrtSplList

The CrtSplList procedure creates a list of spool file entries and stores the list in a user space.

The CrtSplList procedure can be used to enumerate the current list of spool files for a user, job, form type, user data or ASP.  The generated output is stored in the specified user space and contains the same format as that generated by the OS/400 QUSLSPL API, plus an additional customized format.

count  CrtSplList(
 szUserSpace 21A    Const OPTIONS(*NOPASS:*OMIT)  
 szAPIFmt     8A    Const OPTIONS(*NOPASS:*OMIT) 
 szUser      10A    Const OPTIONS(*NOPASS:*OMIT) 
 szOutQ      20A    Const OPTIONS(*NOPASS:*OMIT) 
 szFormType  10A    Const OPTIONS(*NOPASS:*OMIT) 
 szUserData  10A    Const OPTIONS(*NOPASS:*OMIT) 
 nASP        10I 0  Const OPTIONS(*NOPASS:*OMIT) 
 szJobName   10A    Const OPTIONS(*NOPASS:*OMIT) 
 szJobUser   10A    Const OPTIONS(*NOPASS:*OMIT) 
 szJobNbr    10I 0  Const OPTIONS(*NOPASS:*OMIT) 
 szRtnStruct 88A    OPTIONS(*NOPASS : *OMIT)
)

See also: CrtUsrSpace GetNextEntry

Parameters

szUserSpace
[input Char(21) const]  This parameter consists of two parts (1) in the first 10 positions, the name of the user space, and (2) in the second 10 positions, the name of the library in which the user space is located. For example:
 *...v....1....v....2
'MYSPACE   QTEMP     '
 

An alternative syntax is also supported for the user space parameter. The alternate syntax allows you to specify the user space name similar to that of an OS/400 CL command; it may be specified using qualified name syntax, as follows:

 *...v....1....v....2
'QTEMP/MYSPACE       '
 

The qualified user space name is MYSPACE in the QTEMP library. Either syntax is acceptable.

 
The special value '*' (an asterisk) may be specified, which causes the  procedure to use the default user space (created in the QTEMP library). Any data currently stored in the default user space is replaced.
 
If the user space does not exist, the procedure will create it automatically.
 
szAPIFmt [optional] DFT('SPLF0100')
[input Char(10) const]  The name of the API format to use to generate the list. Any format supported by the QUSLSPL API may be specified, including those formats that may become available in a future release. The current available formats are as follows:
szUser [optional] DFT(*ALL)
[input Char(10) const]  The name of the user profile whose spool files will be included in the list. The special value *ALL may be specified to indicate that all entries are returned. If a Job Name, number of job user are specified, this parameter is ignored.
szOutQ [optional] DFT(*ALL)
[input Char(10) const]  The name of the user profile whose spool files will be included in the list. The first 10 positions may contain the name of the output queue and positions 11 through 20 may contain the output queue library name. The special value *ALL may be specified to indicate that all entries are returned. If a Job Name, number of job user are specified, this parameter is ignored.
szFormType [optional] DFT(*ALL)
[input Char(10) const]  The name of the user profile whose spool files will be included in the list. The special value *ALL may be specified to indicate that all entries are returned. If a Job Name, number of job user are specified, this parameter is ignored.
 
szUserData [optional] DFT(*ALL)
[input Char(10) const]  The name of the user profile whose spool files will be included in the list. The special value *ALL may be specified to indicate that all entries are returned. If a Job Name, number of job user are specified, this parameter is ignored.
nASP [optional] DFT(-1)
[input Int(4) (10i0) const]  The ASP of the spool files to include on the list. The special value -1  may be specified to indicate that no ASP information is considered; 0 means include all spool file in all ASPs; 1 means include spool files from the System ASP.  Other ASPs (2 to 32) may also be specified. If a Job Name, number of job user are specified, this parameter is ignored.
szJobName [optional] DFT(*)
[input Char(10) const]  The name of the job whose spool files will be included in the list. The special value * may be specified to indicate that the current job is requested. When this parameter contains an asterisk (*), the szJobUser and szJobNbr parameters must be blank. If this parameter is specified, the szUser, szOutQ, szFormType, szUserData, and nASP are ignored..
szJobUser [optional] DFT(' ')
[input Char(10) const]  The name of the user profile for the job name specified on the szJobName parameter. If szJobName equals '*' this parameter is ignored. This parameter may only be specified when the szJobName is specified. 
 
szJobNbr [optional] DFT(' ')
[input Char(6) const]  The number for the job specified on the szJobName parameter. If szJobName equals '*' this parameter is ignored. This parameter may only be specified when the szJobName is specified. 
szRtnStruct [reserved]
[input/output Struct(88) ]  This parameter is reserved for future use and does not need to be specified.

Return Value

The number of entries generated on the list is returned.

If the function fails, check the XT_ERROR data structure's subfield XT_ERRMSGID for the error message ID indicating why the list was not created.

Remarks

If the user space specified on the szUserSpace parameter does not exist, it is created by this procedure.

The szUser, szOutQ, szFormType, szUserData, and nASP parameters work together to allow you to select the specific list of spool files desired. If omitted, they default to *ALL. However, if a Job Name, Job User, and Job Number parameter are specified, the first set of parameters are ignored and may be specified as *OMIT or as a variable with some other value; but they are ignored.

Example

To create a list of field names and their attributes in the FIELDLIST user space, the following example may be used:

      /INCLUDE qcpysrc,lists
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++
     D szUS            DS                  
     D  szUSName                     10A   Inz('SPOOLFILES')
     D  szUSLibName                  10A   Inz('QTEMP')
.....CSRn01..............OpCode(ex)Extended-factor2+++++++++++++++++++++++++++
     C                   CallP     CrtSplList(szUS : '2')

In this example, a list of all spool files on the entire system is created using the XT_SFL0200 data structure as the format.

Example 2 - Delete Old Spool Files

The following RPG IV program can be used to delete spool files from the system for a specific user profile, that are an indicated number of days old.  The command definition source that follows the RPG IV source allows ease of use of the program by allowing the end user to specify the number of days old a spool file should be before it is deleted and the user profile whose spool files will be deleted.

     H BNDDIR('XTOOLS' : 'QC2LE') OPTION(*SRCSTMT:*NODEBUGIO)

     H  DFTACTGRP(*NO) ACTGRP('XTOOLS')

 

     D DltMySPlf       PR

     D  nDaysOld                      5U 0 OPTIONS(*NOPASS)

     D  szUsrPrf                     10A   OPTIONS(*NOPASS)

 

     D DltMySPlf       PI

     D  nDaysOld                      5U 0 OPTIONS(*NOPASS)

     D  szUsrPrf                     10A   OPTIONS(*NOPASS)

 

      /INCLUDE XTOOLS/QCPYSRC,cprotos

      /INCLUDE XTOOLS/QCPYSRC,utils

      /INCLUDE XTOOLS/QCPYSRC,lists

 

     D MySplf          S                   LIKE(XT_SFL0200)

 

      **  How long before we delete the SPLF?

     D DFTExpired      C                   Const(14)

 

     D szUser          S             10A   Inz(*USER)

     D today           S               D   Inz(*SYS)

     D crtDate         S               D   DatFmt(*ISO)

     D nExpired        S             10I 0

     D nDays           S             10I 0

     D nSplf           S             10I 0

     D nPos            S             10I 0

     D I               S             10I 0

     D dltsplf         S             64A   Varying

     D cmdShell        C                   Const('DLTSPLF FILE(%s) JOB(+

     D                                           %s/%s/%s) SPLNBR(%s)')

 

     C                   eval      *INLR = *ON

 

     C                   if        %Parms >= 1

     C                   eval      nExpired = nDaysOld

     C                   else

     C                   eval      nExpired = DFTExpired

     C                   endif

 

     C                   if        %Parms >= 2

     C                   if        szUsrPrf <> *BLANKS

     C                              and %subst(szUsrPrf:1:1) <> '*'

     C                   eval      szUser   = szUsrPrf

     C                   endif

     C                   endif

 

      **  Create a list of Spool Files for the user

     C                   eval      nSplf = CrtSplList('*':'SPLF0200': szUser)

     C                   if        nSplf <= 0

      **  If there are not spool Files for the user, log it and get out.

     C                   callp     WrtJoblog('No spool files found for +

     C                                        user %s': szUser)

     C                   endif

 

      **  Retrieve each spool file from the list.

     C                   dow       GetNextEntry('*': nPos : mySplf) > 0

     C                   eval      XT_SFL0200 = mySplf

     C     *CYMD0        MOVE      TK_QUSDTOPN   CrtDate

     C     Today         SubDur    CrtDate       nDays:*DAYS

 

      **  If the spool file was created at least 

      **  nExpired-days old delete it.

     C                   if        nDays >= nExpired

     C                   eval      dltsplf = FmtText(cmdShell: TK_QUSSPLFNM :

     C                                                 %TRIMR(TK_QUSJOBNBR) :

     C                                                 %TRIMR(TK_QUSUSRNAM) :

     C                                                 %TRIMR(TK_QUSJOBNAM) :

     C                                                  %Char(TK_QUSSPLNBR) )

     C                   callp     wrtjoblog(dltsplf)

     C                   callp     system(dltsplf)

     C                   endif

     C                   enddo

     C                   return

 

DLTMYSPLF -  Command definition source 

            CMD        PROMPT('Delete my old spool files')
            /*   Command processing program is: DLTMYSPLF  */       
            PARM       KWD(DAYS) TYPE(*UINT2) DFT(14) EXPR(*YES) +  
                         PROMPT('Number of days to qualify')        
            PARM       KWD(USRPRF) TYPE(*NAME) LEN(10) +            
                         DFT(*CURRENT) SPCVAL((*CURRENT)) +         
                         EXPR(*YES) PROMPT('User profile')