An old application running S/36e creates workfiles in library QS36F with the following name-structure:
ABC.aaXb where 'aa' and 'b' are random characters, and the 'X' is constant.
These workfiles are sometimes not deleted by the application even if they should have been. Once in a while a data-entry program cannot execute since it tries to create a workfile that is already there; - therefore we want to make this 'global' delete.
We have no sourcecode so we want to create a batch-program which can run unattended during nighthours.
We have three ideas on how to create a solution:
1. Make a CLP which reads QSYS2/SYSTABLES and select the filenames that qualify for deletion.
My proposed CL pseudo-code:
MONMSG .... GOTO ENDPGM
IF %SST(TABLE_SCHEMA = 'QS36F') DO
IF %SST(TABLE_NAME, 1, 4) = 'ABC.' AND +
%SST(TABLE_NAME, 7, 1) = 'X' +
2. Another approach could be to use SQL.
My proposed pseudo-code:
SELECT TABLE_NAME, TABLE_SCHEMA FROM QSYS2/SYSTABLES
WHERE TABLE_NAME = 'QS36F'
AND SUBSTR(TABLE_NAME 1 4) = 'ABC.'
AND SUBSTR(TABLE_NAME 7 1) = 'X'
DROP TABLE QS36F/TABLE_NAME
How can this be put together into a batch-program ?
3. Use QSHELL
Can this be used at all in a non-IFS environmen? We like the thought of using the SELECT and PIPE functionality of QSHELL.
Any comments and thoughts on this task are most welcome.