Who is using an AS/400 file

5 pts.
Tags:
RPG
I want to clear a file in RPG, but find that it is in use. How can I determine, programatically, what user(s) is locking the file?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • graybeard52
    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
    3,115 pointsBadges:
    report
  • graybeard52
    Also, check out PRCOBJLCK command at http://systeminetwork.com/article/easily-respond-object-and-record-lock-events
    3,115 pointsBadges:
    report
  • Andrewsdad
    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.
    25 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following