The IBM i CL command Reorganize Physical File Mbr (RGZPFM) removes deleted records from a specified member of a physical file and, optionally, reorganizes that member. It’s a handy command to know about but reorganising physical files member by member can become a very painful process if you have a lot of files to reorganise (after manually purging a large volume of test data, for example).
I did, at a previous employer, have access to a RGZLIB command. This reorganised all of the physical files in a library and made for a much more convenient purge. Unfortunately, this is ont a system supplied CL command and my current emplyer doesn’t have it.
So I wrote my own version.
RGZLIB is a simple command that will reorganise all of the physical file members in a selected library. Depending on the size of the library to be reorganised (and the size of the files in that library) this process can take a while to run, so I strongly suggest that you submit the command to batch.
My original plan was to write this in RPG and include some additional file clean-up options. However, it turns out that there is no API to retrieve a list of files in a library so the program, as it stands, is a very simple CL affair. If I do code up the additional functionality, I will put it into a seperate command to avoid over-complicating things.
As ever, the source is available on GitHub and you are free to browse or download it from there.