Flat File Processing - Exclusive read


I have a UBE that is reading and processing an external flat file. Is there a way that I can detect whether the flat file is in use to prevent concurrent processing. The ube creates a "progress" file when it starts whose existence prevents any subsequent run. However, if someone has the file open in say notepad, I am unable to detect this and the process runs to completion. The open file BSFN did not return an error. I also tried copying the file to another folder and deleting but BSFN B4700230 did not report any errors. Is there a BSFN I can use to give me exclusive read access
Not sure if this is going to help as I am not sure why you need exclusive read lock. Read lock is normally shared.
Make an entry into a custom table when your program start reading particular file. Check if entry for that file exists in the custom table. Delete entry when the file is read so that other cam read.
I've not explained the issue properly. There is an external system creating the flat file and an a job on the scheduler that runs the UBE to read the file and back it up. How can I prevent the UBE opening and processing the file while the external process is in the process of creating it.
We had similar scenario with larger files being written from external system. This was causing JDE program to read partial files to process. If my memory serves correct, we used another folder (lets say DUMMY)in which the external program creates the file. From that folder (DUMMY) we used folder scripts to move to Final folder (lets say FINAL) where JDE program reads it. Folder script runs in a scheduler at a time interval.
Another simple way is to create the file with some other extension and thereafter when the file is completely written, rename the file to the required format.
We usually use a control file which is an empty file with a specific name. If it exists then import/process the data file. When the import/processing has completed the control file is deleted and the data file is either archived or deleted.