“Finding Save Files” might sound like a Disney “Straight to TV” sequel to “Finding Nemo” but no, it’s much more pleasurable than that 😉 Few of us enjoy tidying up after ourselves in our home life and in my experience, even less of us like to do it in their IBM i work life.
In this GDPR world in which we now live, we are obliged to track and remove copies of data that we no longer need and one of the most commonly overlooked (in the IBM i world) is data stored in Save Files.
This is hardly surprising as the data stored inside them is not indexed on the system, so these opaque blobs tend to sit around our in systems, hiding in plain sight and gathering virtual dust.
How do I find Save Files on IBM i?
Unfortunately, our friends in Rochester never created a WRKSAVF command. So, we have to be a little more creative. Save files do show on the WRKF command but they do rather tend to get lost in the crowd of the myriad of files we have on our systems. To identity SAVFs from the other file types, we need to look at the file attribute. In the following example we see a list of objects that are all counted as files on IBM i:
Authors Note: If someone wants to create an RFE for a WRKSAVF command, I would vote for it.
Where to start?
What we need as a starting point is an easy to access, easy to maintain list of all the objects on a system. Once we have that querying it to find files with a particular attribute is child’s play.
Fortunately, IBM i has the RTVDSKINF command that will do just that for you, conveniently maintaining file QUSRSYS/QAEZDISK.
You can run the RTVDSKINF when ever you like but it will take a while to complete as it need to read through every object in every library on your system. So, this is best run in batch.
Whenever you run this command it replaces the data in QUSRSYS/QAEZDISK. So make sure you finished or copied the data you want from the file before running it again.
ProTip: Use the GO DISKTASKS menu, Option 1 to schedule a regular automatic collection:
Querying the QAEZDISK File
This is just like any other file, so interrogate it in the way that you like best, write a program, WebQuery, Query400, STRSQL, etc.
Or, if you are like me, you use the ACS RUNSQL Scripts function these days, then run the following SQL statement:
select Diobli, Diobnm, Diobat, varchar_format(Diobsz, ‘9G999G999G999G999’) as “Size in Bytes”
where Diobat = ‘SAVF’ AND Diobow Not Like ‘Q%’
order by Diobsz DESC
In this case I sorted the list of SAVFs by size, regardless of what library they are in. I also omitted the ones starting with a Q as these tend to belong to IBM. I don’t recommend you do that unless you know it is safe to do so.
The beauty of the RUNSQL script is that is it so easy to customise it your needs, so you can tune your specific requirements. Now you know where these save files are hiding you can easily maintain them.
i-UG goes Hybrid
Our next User Group Meeting will be in December and this time it’s a Hybrid. It will of course still be available Virtually via Zoom but also in person and the Mount Hotel in my home town of Wolverhampton. For more details check out www.i-ug.co.uk
Hope to see you there.
Massimo Duca says
You can also easily get this information with DB2 Services:
SELECT objname, objattribute, objsize, last_used_timestamp
FROM TABLE (qsys2.object_statistics(‘*ALLUSR’, ‘*FILE’)) t
WHERE objattribute = ‘SAVF’
Better run the statement in batch with RUNSQL command, directing the output into a table.
SBMJOB CMD(RUNSQL SQL(‘CREATE TABLE mylib.savefiles AS (SELECT
objname, objattribute, objsize, last_used_timestamp
FROM TABLE (qsys2.object_statistics(”*ALLUSR”, ”*FILE”)) t
WHERE objattribute = ”SAVF”)
WITH DATA ‘) COMMIT(*NONE)) JOB(SAVF)
Giovanni Ramajola says
Exactly! I will use this query to find and files! Thanks a lot
MOHAMMAD JAHED HOSSAIN BIJOY says
Very helpful document.