Try the CHGDOCD command. Dave
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
Locking an IFS object
Collapse
X
-
Locking an IFS object
What kind of PC files are you processing in the folder? What extension (.TXT, .CSV, .XLS, etc)? I've played around the the 'open' API and mode O_SHARE_NONE before. It doesn't seem to work for some file types though such as MS Word DOCs, which seem to lock the hidden file it creates when you open the document, and not the document itself. Chris
Code
-
Locking an IFS object
I've just had a look at the CHGDOCD option (thought it would be the quickest and easiest to implement but can't see how this would allow you to lock a file. It looks as if this can only be used with Documents and folders, not objects accessed in the IFS using WRKLNK
Comment
-
Locking an IFS object
I have a little background job which every minute or so uses the opendir & readdir functions to process the streamfiles within an IFS directory. Each file read is simply copied using CPYFRMIMPF to move the contents into a physical file. Every now and then the CPYFRMIMPF fails as it is unable to lock the object. Is there a command/function I can use similar to ALCOBJ which will allow me to lock the file before copying and if I can't lock the file, Iter in a loop until I can. I had tried using the %ERROR %BIF on the Call to QCMDEXC CMD('CPYFRMIMPF etc') to detect a failure, but this doesn't seem to work in this scenario Any help would be appreciated
Comment
-
Locking an IFS object
Instead of using QCMDEXC, have you tried using the QCAPCMD API? We've had good luck using this with its standard API error code parameter, which can return exception messages to your RPG program if the command fails. It is about as close as you can get to a MONMSG in RPG. This won't help you allocate the file, but it will let you retry the command if you determine it failed due a lock problem. Just make sure you limit the number of automatic retries allowed.
Comment
-
Be careful with CHKOUT, if you check out an IFS file you cannot use that object if you try to use it in a secondary called program. The best solution I've come up with is to move the IFS file (using the MOV command) to an "In process" folder.Last edited by dscorca5; 08-22-2019, 06:54 PM.
Comment
Comment