How to know the end of file??
Posted: Tue May 17, 2011 4:17 pm
Hi All,
I facing an issue while reading a file. I have program which will read a file and write into another file. Issue is last record(only last record) in the input file is written twice into output file. If input file is having 2 records , my output is having 3 records.
below is my code :
When i checked with DISPALY statements, found that EOF flag (EOF-FOUND ) is set to true after reading the last record twice i.e if i/p file is one record , EOF flag is set only after reading 2 records (reading last record twice).
Example : i/p file is having only one record in the below example output)
Below is output from spool :
PROGRAM DTM00201 STARTS
CALLED PROCESS 0001 TIMES
WRITING TO UNQ FILE
CALLED PROCESS 0002 TIMES
WRITING TO UNQ FILE
Can anyone suggest what needs to done.
Thanks in advance
I facing an issue while reading a file. I have program which will read a file and write into another file. Issue is last record(only last record) in the input file is written twice into output file. If input file is having 2 records , my output is having 3 records.
below is my code :
READ IN210-INP-FILE
AT END SET EOF-FOUND TO TRUE
NOT AT END SET NOT-EOF-FOUND TO TRUE
END-READ
AT END SET EOF-FOUND TO TRUE
NOT AT END SET NOT-EOF-FOUND TO TRUE
END-READ
When i checked with DISPALY statements, found that EOF flag (EOF-FOUND ) is set to true after reading the last record twice i.e if i/p file is one record , EOF flag is set only after reading 2 records (reading last record twice).
Example : i/p file is having only one record in the below example output)
Below is output from spool :
PROGRAM DTM00201 STARTS
CALLED PROCESS 0001 TIMES
WRITING TO UNQ FILE
CALLED PROCESS 0002 TIMES
WRITING TO UNQ FILE
Can anyone suggest what needs to done.
Thanks in advance