CLNSPL - cleanup old spools

page d'accueil
Boite à outils

Cette page a été mise à jour le14 septembre 2009.
Contact

Welcome page
Tools box

Target :

delete old spool files depending on their age

Characteristics :

RPG, User space and pointers : the shortest code I've do to explore a list of spools

Sample :

 Cleanup old spools (CLNSPL) 

Type choices, press Enter.

standard spools life span . . . 7 1-99, *NOMAX
Saved spools life span . . . . . 21 1-99, *NOMAX
standard joblog life span . . . 2 1-99, *NOMAX
Saved joblog life span . . . . . *NOMAX 1-99, *NOMAX












Bottom
F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display
F24=More keys


Yet an other spool cleaner.

I made this tool a day I was on a site without internet access. (yes, it's already possible today). Not possible to get a free existing tool on the web.
Because I was in position to write again a spool-list-reader, I decide to make it a little spicy.

I've try to answer this question : what is the lesser number of RPG calculation statement required to walk a spool-file-list ?

The answer is 4 :

the first is the API to get the list


// get list of spools 
quslspl(usrspc// user_space
: 'SPLF0300' // Format
: '*ALL' // UserName
: '*ALL' // OutqName
: '*ALL' // FormType
: '*ALL' // UserData
: errcode );

the second if the API to get a pointer on the list (LAH mean List-Api handler)

// use LAH as a mask to format & read the user space 

qusptrus(usrspc : pLAH);

the third is a FOR to loop the list :

for iSpl= 0 to lah.count - 1; 

the forth is to get the data from one entry of the list :

// get data to load element 

psplf0300 = pLAH + LAH.Data_Offset + iSpl * LAH.entry_Size ;

Now, you know what is the heart of this tool, you can look at the code.

CLNSPLR rpg program is finally 239 lines long ... plus the JP4* include toolbox.

Debug mode : if you want to test the tool, you can change it to just list the spools to delete :

0222.00            message('CPF9898':cmde:'':'QCPFMSG');
0223.00            rc = c_system(cmde );                

at 222, the RPG send a message to the joblog. CMDE variable contains a DLTSPLF command.
at 223, the command is executed.
For test purpose, just comment line 223.

Versionning

last version : How to upload to my 400

to compile :

CHGPFM FILE(JPLTOOLS) MBR(CLNSPL) SRCTYPE(CMD) TEXT('Clean old spools') 
CHGPFM FILE(JPLTOOLS) MBR(CLNSPLR) SRCTYPE(RPGLE) TEXT('Clean old spools')

CRTCMD CMD(CLNSPL) PGM(CLNSPLR) SRCFILE(JPLTOOLS)
CRTRPGMOD MODULE(CLNSPLR) SRCFILE(JPLTOOLS) OPTION(*NODEBUGIO *SRCSTMT *SHOWCPY *SECLVL *EXPDDS) DBGVIEW(*ALL) REPLACE(*YES) TGTRLS(V5R3M0) ENBPFRCOL(*FULL)
CRTPGM PGM(CLNSPLR) BNDDIR(QC2LE JPLTOOLS) ACTGRP(JPLTOOLS) OPTION(*DUPPROC) TGTRLS(V5R3M0)

The source code is provided as an open source tool under the GNU General Public License, version 2.  In summary, this license specifies:

By clicking the download link you acknowledge and agree to the terms of the license.

Download the (zipped) SAVF containing the JPLTOOLS : the source file, the message file, the bnddir

THIS TOOLBOX IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS TOOLBOX, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.