Hi,
when I am reading empty file, it gives error status as 10...
But, i just wanted to know , How to check if file is empty in microFocus cobol without reading the file??
I need to display the message to user as "No record in CM file" in case file is empty without reading.
See my logic
open input CM-FILE
Read CM-FILE-REC
Also, when i Read CM-FILE-REC , immediately given error status as 10 and abended with error and my complete application is getting closed.
after read , just i thought to keep condition to check status and send message to user ,then no use...
Also, when i Read CM-FILE-REC , immediately given error status as 10 and abended with error and my complete application is getting closed.
after read , just i thought to keep condition to check status and send message to user ,then no use...
I'll answer your problem/error first, then try and answer the question you actually asked.
1. To avoid the read generating an error message and existing the program, add a DECLARATIVE SECTION. Add this file to that section. This traps all file errors, and you can decide what (if anything) to do with the error. After the declarative section finishes processing, if it simply exits, control returns to the program right after the IO command that triggered the error. I recommend this method.
2. If the file is sequential or relative, then an empty file would be zero bytes. You can use C$FILEINFO utility in this case to see what the size is before opening the file.
3. If the file is indexed, you can use the I$IO utility to "open" the file, then use the INFO-FUNCTION to find out how many records are in the file