E9.1 Trouble Deleting Flat File

CHo

VIP Member
Hi Y'all.

I have two files -- one master and one detail file on local Windows directory. I am testing the files on local Windows directory.
The master file is read and processed first and then the detail file is then read and processed. The files are independent of each other.

The master file needs to be deleted after processing. This does not work.

The detail file needs to be archive and then deleted after processing. This works.

B4700230 Delete or Copy Flat File BSFN is used for both of the files. I have tried action codes 3 and 1 to delete the master file and both of the action codes do not delete the master file.

The directory path for the master file is correct. I have full access to the master file.

What am I missing? Should I use a different BSFN to delete the master file?
 
To add to Don's excellent question, if you're using a BSFN like B34A1010 that gives you a file handle when you open the file, you should use that file handle to close the file before trying to delete it.
 
Are your directory for Master and details different?. if yes then i would check the access rights for the master directory for delete.

If all is correct then a debug trace should give you more details on failure.
 
Are you closing the master file after you finish processing it?
Yes, I close it in the End Section. The master file is processed in the Initialize Section. So, can the close file remain in the End Section or does it need to be immediately after the end of processing in the Initialize Section?
 
Are your directory for Master and details different?. if yes then i would check the access rights for the master directory for delete.

If all is correct then a debug trace should give you more details on failure.
The master and the detail files are in the same directory.
 
Yes, I close it in the End Section. The master file is processed in the Initialize Section. So, can the close file remain in the End Section or does it need to be immediately after the end of processing in the Initialize Section?
That depends ... when do you try to delete the master file? What matters is you most first close it before you attempt to delete it. I would close it as soon as I was done processing it.
 
Hi. I have resolved it in a weird way.
I put in Open File in my code. When I ran UBE, the Open File deleted the detail file name in the master file. I manually recreated the master file. I reran the UBE without the Open File line and the master file was deleted automatically.
I think the file pointer must have been corrupted in some way.
Bottom line, issue resolved.
 
Sometimes, I'm used operating system commands for delete, or copy files when it given problems.
Regards.
 
Back
Top