LISTFILE. It’s Not Your Father’s LISTF Anymore
Have you explored the LISTFILE functionality recently? There are two features in particular that are particularly handy when combined together. These features are the selection equation to select files based on attributes such as file code or access options; and the output format 9 which shows what processes are accessing a file.
Troubleshooting Image database locks means issuing a SHOW LOCKS command in DBUTIL. Diagnosing locks on other types of files used to be more difficult. You can create the creating an equivalent command for flat files and KSAM files by combining LISTFILE with SELEQ and FORMAT=9. This will produce a list of files that are locked, the process(es) locking the file(s), and processes that are waiting for the locks to be released. In the following example there is one file selected. Two processes are shown that have the file open. The second process listed has the file locked. You can tell this because it contains FLOCK underneath OWNER. The first process is waiting for the lock to be released based on the FLOCK being shown under WAITER.
:listfile @.pub;seleq=[access=locked];format=9
********************
FILE: TESTFILE.PUB.WERTH
2 Accessors(O:2,P:2,L:2,W:2,R:0),Share
#S837 DW,USER.WERTH P:1,L:1,W:1,R:0 REM : 192.6.1.63
#P86 (PROG2.SOURCE.WERTH)
ACCESS: W-excl REC#: 0 FNUM: 9
LOCKS--Owner-- --Waiter--
FLOCK
#S835 DW,DOUG.WERTH P:1,L:1,W:1,R:0 REM : 192.6.1.63
#P97 (PROG1.SOURCE.WERTH)
ACCESS: W-excl REC#: 0 FNUM: 9
LOCKS--Owner-- --Waiter--
FLOCK
Here are a few other examples:
Obtain a list of COBOL source files in an account with this command:
:listfile @.@.prod;seleq=[code=EDTCT];format=2
Display all Powerhouse subfiles and who is accessing them:
:listfile @.@.prod;seleq=[code=644];format=8
Display all Image databases:
:listfile @.@.@;seleq=[code=-400];format=2
Here are the allowable options for the SELEQ parameter:
[FTYPE = KSAMXL|SPOOL]
[OBJECT = ACCT|GROUP|FILE|DIR|HFSDIR|SYMLINK]
[CODE = filecode mnemonic|number|PRIV]
[ACCESS = INUSE|OPEN|LOCK[ed]|EXCL[usive]]
As you can see LISTFILE has become a very powerful command, no longer limited to choosing files solely on the file name.