It's the end of the year, so now is a good time to clean up your DASD. Often, I find that when I create a compiler listing or sample report, I leave the corresponding spool file out there for what seems like forever. So I created the Delete My Old Spool Files (DLTOLDSPLF) command.
The DLTOLDSPLF command allows you to easily clean up older, unneeded spool files. You pass in the number of days old a spool file has to be before it is deleted and optionally a user profile name, and poof, they're gone!
To delete my own spool files that are at least 30 days old, I would run the following command:
DLTOLDSPLF DAYS(30)
Of course, you should only delete your own user profile's spool files, so the USRPRF parameter defaults to USRPRF(*CURRENT). But because we're programmers, we can, of course, delete almost anything we want (Sarbanes-Oxley, turn your head for a second). To delete all the spool files that are at least 60 days old for the user profile named BOB, you would run the following command:
DLTOLDSPLF DAYS(60) USRPRF(BOB)
Provided you have regular OS/400 or i5/OS authorization to these spool files, poof, they're gone!
I'm using the CRTSPLLIST() procedure from the xTools *SRVPGM to build the list of spool file entries. If you don't have that service program installed, you can call the QUSLSPL API, the prototype for which is included at the end of this article. Using the CRTSPLLIST procedure reduces the parameters that I need to specify. It also saves space in this newsletter and allows me to publish more powerful code with fewer statements. In a few weeks, I will present the Delete Old IFS Files (DLTOLDIFS) command, which deletes files from a specific directory of the IFS once they become a specified number of days old.
The source code for DLTOLDSPLF is available online, but I have reproduced it here.
The command definition source code for the DLTOLDSPLF command is listed below.
DLTOLDSPLF: CMD PROMPT('Delete my old spool files')
/* Command processing program is: DLTOLDSPLF */
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')
To view this source member online or to download it directly, follow this link.
The RPG IV source code for the DLTOLDSPLF program is listed below:
H BNDDIR('XTOOLS/RPGLIB' : 'QC2LE') H OPTION(*SRCSTMT:*NODEBUGIO) H DFTACTGRP(*NO) ACTGRP('XTOOLS')
***************************************************** ** An example program that uses the RPG xTools. ** ** ----------------------------------------------- ** ** Delete Old Spool Files ** *****************************************************
** See also... ** QCMDSRC(DLTOLDSPLF)
D DltOldSplf PR D nDaysOld 5U 0 OPTIONS(*NOPASS) D szUsrPrf 10A OPTIONS(*NOPASS)
D DltOldSplf PI D nDaysOld 5U 0 OPTIONS(*NOPASS) D szUsrPrf 10A OPTIONS(*NOPASS)
** 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
** All DLTSPLF commands that are run, are ** posted to the joblog as informational messages. D cmdShell C Const('DLTSPLF FILE(%s) JOB(+ D %s/%s/%s) SPLNBR(%s)')
C eval *INLR = *ON
** If the caller passed in the number of days-old to delete, ** use that value, otherwise use the default of 14 days. C if %Parms >= 1 C eval nExpired = nDaysOld C else C eval nExpired = DFTExpired C endif
** If the caller passed in a specific user profile, ** use that profile, otherwise use the default *CURRENT. 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 profile. ** The xTools SPLF0200 format is returned. Note that this format ** is a consolidation of the screwy format that IBM created. ** On later releases of OS/400, SPLF0300 was added by IBM to do ** what is already being accomplished by the SPLF0200 format in xTools. ** Since I want this to work on V4R5 and later, I'm using the xTools.
C eval nSplf = CrtSplList('*':'SPLF0200': szUser) C if nSplf <= 0 C callp WrtJoblog('No spool files found for + C user %s': szUser) C endif
** Iterate through the list of spool file entries that were generated. ** If the date the spool file was created is older than our "days old" ** setting, then issue a DLTSPLF command for that spool file. C dow GetNextEntry('*': nPos : mySplf) > 0 C eval RTK_SFL0200 = mySplf C *CYMD0 MOVE TK_QUSDTOPN CrtDate C Today SubDur CrtDate nDays:*DAYS C if nDays >= nExpired ** The xTools' FMTTEXT procedure allows us to easily ** create the DLTSPLF command string. C eval dltsplf = FmtText(cmdShell: TK_QUSSPLFNM : C %TRIMR(TK_QUSJOBNBR) : C %TRIMR(TK_QUSUSRNAM) : C %TRIMR(TK_QUSJOBNAM) : C %Char(TK_QUSSPLNBR) ) ** Log the DLTSPLF command to the joblog before running it. C callp wrtjoblog(dltsplf) ** Delete the spool file. C callp system(dltsplf) C endif C enddo ** ENDPGM: C return
To view this source member online or to download it directly, follow this link.
The prototype for the QUSLSPL API is as follows:
********************************************************* ** E N U M E R A T E S P O O L F I L E N A M E S L I S T ********************************************************* D QUSLSPL PR ExtPgm('QUSLSPL') D szUserSpace 20A Const D Format 8A Const D UserName 10A Const D OutQ 20A Const D FormType 10A Const D UserData 10A Const D apiError Like(QUSEC) OPTIONS(*NOPASS) D JobID 26A Const OPTIONS(*NOPASS) D RtnFldKeys 10I 0 Const OPTIONS(*NOPASS)
D Dim(24) D FldKeyCnt 10I 0 Const OPTIONS(*NOPASS) D ASP 10I 0 Const OPTIONS(*NOPASS)
Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Languagehas been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG Worldconference for RPG programmers.
Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.
This book provides an amazingly comprehensive introduction to the concepts while at the same time delivering enough technical detail to make you productive very quickly.
Today, it's all about input and output. Getting data into the IBM i from non-traditional sources and then displaying it back out again in varied formats. But where can you go to learn all that you need to know about this critical skill?
Too valuable to be classified as merely excellent certification material, this book should also rightly take its place on DB2 DBA bookshelves as a solid day-to-day DB2 reference.
Whether you want to obtain an IBM certified DB2 professional certification or simply become well-rounded in the fundamental concepts of DB2 and general database theory, this is your book.
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
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:
LATEST COMMENTS
MC Press Online