IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to delete/update records in a sequential file using COBO


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
manugeorge2004

New User


Joined: 17 Jun 2009
Posts: 38
Location: Denver

PostPosted: Wed Nov 25, 2009 10:38 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Nov 25, 2009 10:44 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 25, 2009 11:15 pm
Reply with quote

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
View user's profile Send private message
manugeorge2004

New User


Joined: 17 Jun 2009
Posts: 38
Location: Denver

PostPosted: Wed Nov 25, 2009 11:24 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 25, 2009 11:29 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Nov 25, 2009 11:46 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 5
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
Search our Forums:

Back to Top