On most systems I work on there are simply far too many spool files. Spool files are no doubt a useful source of information but what is also in no doubt is that spool file maintenance is one of the last tasks on anyone’s agenda.
However, on every system there are spool files which are important and trying to control them isn’t easy. On most systems users can all too easily delete other users spool files as well as their own.
What if there was a simple method of converting important spool files to .pdf or .txt and copying them to the IFS or even a Windows Share? Well, good news, there is and it is free.
By using the CPYSPLF command with the right parameters you can create an archive of spool files with .pdf and .txt extensions that can be opened by your favourite reader / editor.
Divide and Conquer
Taking this idea one step further you could create a list of folders by application or subject to make finding your spool files easy. For example, here’s a subset of a list of top-level folders created on the IFS as a repository.
Then taking production as the example inside that more folders
Then taking the productionplan folder inside that is a list of .pdf files, these have been named using a reversed date format of yymmdd – hhmmss this keeps them nicely in chorological order, as shown below:
To setup the folders I use Navigator for i. There are commands to achieve this on the green screen but I prefer the GUI interface of Navigator for i these days. I find Firefox is the best browser to use with Navigator for i.
Navigate to File Systems Integrated File System Root
Click on Root to bring up the list of folders already in root on the right hand side
Then click on Actions, then on New Folder
Type in the name of the new folder and click OK
Now create a share for this folder so it can be mapped as a network drive.
Tick the box next to the folder you have just created
Then up to Actions, down to Sharing then Create share
Give the new file share a name, an optional description and set Access to Read Only or Read/Write to suit your needs best.
Pro tip: Default access is Read Only, this is ideal if you want to make this archive immutable, the users can look but not change. If you do want them to be able to make changes, then you will need to select Read/Write but remember you can still restrict the delete function using the IFS Permissions.
Using the same method, you can create sub folders to as many layers as you need to. For this example, I have created a sub folder called archive inside the rowton folder.
Now you have a repository set up you can start to copy spool files to it.
Copying a Spool File to a Text File in the IFS
If you are coding this in a CL program the variables &Spoolfile, &JobNbr, &User and &JobName can be derived from the spool file attributes, you could of course go on to derive the TOSTMF parameter as well to give it a consistent logical name.
CPYSPLF FILE(&SPOOLFILE) TOFILE(*TOSTMF) JOB(&JOBNBR/&USER/&JOBNAME)
TOSTMF (‘/rowton/archive/test01.txt’) WSCST(QWPDEFAULT)
If your command completes successfully, this results in message like the following:
Message ID . . . . . . : CPC3311
Date sent . . . . . . : 28/02/21 Time sent . . . . . . : 09:10:10
Message . . . . : Spooled file copied to /rowton/archive/test01.txt.
Cause . . . . . : Spooled file QPJOBLOG number 10 job 135537/ROWTON/RITMSGW created on system MARK74 on 05/02/21 10:10:01 was copied to /rowton/archive/test01.txt.
Copying a Spool File to a .pdf File in the IFS
Now for the PDF version simply change the WSCST parameter to *PDF
CPYSPLF FILE(QPJOBLOG) TOFILE(*TOSTMF) JOB(135537/ROWTON/RITMSGW)
TOSTMF (‘/rowton/archive/test01.pdf’) WSCST(*PDF)
Message ID . . . . . . : CPC3311
Date sent . . . . . . : 28/02/21 Time sent . . . . . . : 09:15:10
Message . . . . : Spooled file copied to /rowton/archive/test01.pdf.
Cause . . . . . : Spooled file QPJOBLOG number 10 job 135537/ROWTON/RITMSGW created on system MARK74 on 05/02/21 10:10:01 was copied to /rowton/archive/test01.pdf.
ProTip, To create a PDF in this manner, you need to have Licensed Program 5770-TS1 IBM Transformation Service for i (Base and option 1) If these are not loaded you will receive a CPFCE01 message. Don’t worry TS1 is free and shipped on the standard IBM i install images.
Viewing the results in a mapped network drive
This can be really useful in ensuring important spool files are captured as they are created on the IBM i and can with the correct folder structure make finding them much easier for users.
Going back to our examples from earlier, we can now see two files in the rowton\archive folder
ProTip: You can use the Windows Indexing function (other OS have similar) to allow you to search the contents of these files as well as their names. IBM i also has this function in another free License Program called OmniFind but more on that in another article.
i-UG goes Hybrid
We will be returning to the Mount Hotel in Wolverhampton for another Hybrid event on the 18th March, we hope to see you there. For more details go to www.i-ug.co.uk
Leave a Reply