Check for file lock on the IFS in RPG

25 pts.
Tags:
IFS
IFS Lock
RPG
I need a way to check to see if a text file is locked on the IFS in an RPG program. I am running the following command in the rpg program: ReturnInt = Open(%Trim(EntryPath):O_RDONLY+O_SHARE_NONE);. When I do this for an excel file the returnint comes back with a -1 if the file is locked. However if I try the same thing for a text file that is locked the returnint does not get set to -1. Is there some other way to check for a text file lock on the IFS in an RPG?

Answer Wiki

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

Hi,

Can you post a bit more of the code that you’re using for this? I can’t see why the system would “see” any difference between an excel file and a text file. As far as I can tell anything in the IFS is just a file to the system, and the extension (.XLS or .TXT) shouldn’t make any difference.

Maybe it’s a difference between the PC applications accessing the files. Maybe Excel really places a lock on the file, whereas Word or Wordpad, etc doesn’t?

Regards,

Martin Gilbert.

Discuss This Question: 1  Reply

 
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
  • Marvmart
    Here is the basically the whole program. Here is what is happening. If I open an excel file on the IFS and run this program the returnint comes back with a -1 which means the file is locked. If I do the same for a text file the returnint does not come back as a -1. So I am assuming that the program did not find a lock on that file when trying to open the file. I am passing the path where the file is located on the IFS and basically whether I want to lock the file so I can process the file knowing that no one is in the file. EntryPath = %trim(CompletePath) + Null; If WhatToDo = 'L'; ReturnInt = Open(%Trim(EntryPath):O_RDONLY+O_SHARE_NONE); Return; Endif; If WhatToDo = 'U'; CallP Close(ReturnInt); Return; EndIf;
    25 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