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 |
*...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.
- SPLF0100 - Most entries except it does not include the spool file name.
- SPLF0200 - All entries (returns entries in the custom XT_SFL0200 format)
- SPLF0300 - All entries but functions on OS/400 V5R2 and later only.
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.
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.
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.
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
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')