View previous topic :: View next topic
|
Author |
Message |
manugeorge2004
New User
Joined: 17 Jun 2009 Posts: 38 Location: Denver
|
|
|
|
Hi
I am having an issue with processing a sequential file.
I have a sequential file which I am reading record by record.
I want to delete the record once my processing is done.
The reason I am doing this is to have the records which are not processed to be used for a different purpose.
I was thinking I can first read the file sequentially. Then process it. And delete the record after procerssing.
Once I reach EOF, I wanted to close the file and open it again in input mode and read it sequentially and process the other records. I cannot use a sort or anything since business logic is involved.
How can I do this.
Can we delete seq file records in COBOL.
If not can I update the records so that I have some value I can check to skip the record when I read it again.
Please help me with this
Manu |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
manugeorge2004 wrote: |
Can we delete seq file records in COBOL. |
No, nor in anything else that I'm aware of.
manugeorge2004 wrote: |
If not can I update the records so that I have some value I can check to skip the record when I read it again. |
Yes, I believe that COBOL supports the REWRITE function. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you will have to father-son the qsam file.
if after a read, you use the record, do not write it to the new qsam file.
if after a read, you do not use the record, write it to the new qsam file.
the new qsam file will only have records that you did not process. |
|
Back to top |
|
|
manugeorge2004
New User
Joined: 17 Jun 2009 Posts: 38 Location: Denver
|
|
|
|
Actually..I will not be reading the record which I dont process.
I have two files which are sorted for the first few bytes.
I read the first file, read the second file.
I compare the sort keys and do some processing.
The first file is my driver.
After all the records from the first file are read, my loop terminates.
But there will be some extra records in the second file after this.
I need to process those records seperately in the same program.
Thats why i thought I can delete the records from the second file. Then close the file. Then I will open the second file again and process them seperately.
Any suggestions? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
why bother with a complex solution...
at end of file1 set a flag or a high key to stop the two file match process
and keep reading and processing the file2 records only |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Manu, it sounds like you decided what you wanted to do before you posted here. COBOL can quite easily handle what you're wanting to do, and there's no reason to read either file a second time, nor to delete any records from either file -- unless you've decided you have to do so. |
|
Back to top |
|
|
|