this is kind of complicated but...
before clearing the file in rpg, have your rpg program call a cl program that does this command
WRKOBJLCK OBJ(library / filename) OBJTYPE(*FILE) output(*print) , then copy the spoolfile to a physical file. cpysplf. and have your rpg program read the physical file to see if there are locks and what the locking jobs are. If necessary, you can then call a cl program to end the locking jobs, disable the user profiles, and reenable them after your program is finished. I used to do that in a backup job stream.
Last Wiki Answer Submitted: September 24, 2008 3:52 pm by philpl1jb44,220 pts.
All Answer Wiki Contributors: philpl1jb44,220 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
You can clear a file that is in use, if you wan to. Instead if CLRPFM use SQL
DELETE FROM mylib/myfile
It can be run thru RUNSQLSTM or embedded in a RPG pgm
If the file you triing to clear is not a User Controlled (UC) file, you are allocated to it.
Make it a (UC) file and before you open it, use QCMDEXC to clear it (CLRPFM). Then open it.
If the file is in use by someone else, it seems odd to be trying to clear it. That would obviously have serious effects on someone else’s job. Perhaps a review of the application design is in order.
However, the List Object Locks (QWCLOBJL) API will list all jobs that currently have any kinds of locks on a file member. There might be multiple jobs.
You can clear a file that is in use, if you wan to. Instead if CLRPFM use SQL
DELETE FROM mylib/myfile
It can be run thru RUNSQLSTM or embedded in a RPG pgm
Also, check out PRCOBJLCK command at
http://systeminetwork.com/article/easily-respond-object-and-record-lock-events
If the file you triing to clear is not a User Controlled (UC) file, you are allocated to it.
Make it a (UC) file and before you open it, use QCMDEXC to clear it (CLRPFM). Then open it.
If the file is in use by someone else, it seems odd to be trying to clear it. That would obviously have serious effects on someone else’s job. Perhaps a review of the application design is in order.
However, the List Object Locks (QWCLOBJL) API will list all jobs that currently have any kinds of locks on a file member. There might be multiple jobs.
Tom