Have you ever submitted a batch job only to find out it has failed because there happened to be a user session accessing the file? This can be quite annoying.
Here is a command that I set up that allows you, the developer or administrator, to warn users accessing a file, program, data area, etc. and then end their session if needed.
The command is ABTOBJUSR (Abort Object User). It takes a snapshot of what sessions are accessing the file using the WRKOBJLCK (Work Object Lock) command and directs it to a spoolfile. The spoolfile is subsequently copied to a physical file and summarized by device, user profile and job number all within the CLP ABTOBJUSRN.
Once the file has been put together, program control is passed to the CLP ABTOBJUSRX, which then reads through the file and sends a message notifying the user to sign off within the time limit on the first pass. Once the allotted time has passed, the program will then initiate an ENDJOB on the second pass. The program will also check to make sure the user is indeed signed on before it issues the ENDJOB.
Hopefully this will assist you in your programming woes as it has me in the past.
The ABTOBJUSR command aborts users that are accessing the object in question.
About the author: Dwight is superintendent, application support, at Cameco Corp. in Saskatoon, Saskatchewan, Canada, where he manages the operation of the application support group supporting 35 business applications.
Other tips written by Dwight Beech: