Page 1 of 1

Can we delete a record from PS file using a COBOL program

PostPosted: Mon Feb 17, 2014 4:42 pm
by ashwin1990
Can we delete a record from PS file using a COBOL program?

Re: Can we delete a record from PS file using a COBOL progra

PostPosted: Mon Feb 17, 2014 4:44 pm
by NicC
Yes - read the file and create a new file with only the records that you want. Think about it.

Re: Can we delete a record from PS file using a COBOL progra

PostPosted: Mon Feb 17, 2014 4:46 pm
by ashwin1990
Can we use 'DELETE RECORD' command in the COBOL program for PS file. This will save me from creating a new file?

Re: Can we delete a record from PS file using a COBOL progra

PostPosted: Mon Feb 17, 2014 4:54 pm
by NicC
I said "think about it"! A sequential dataset is just that - a long series of bytes one after the other. Your program interprets those bytes. How is it to interpret whatever is left after deleting the record? The read routines only know that each consecutive n bytes is a record and returns them to the program. If you want to have records in the middle of the fdataset that you need to make obsolete then you have to have way of identifying those records when the read routines present them to your program. In any event, you should always create a new dataset just in case something goes wrong during processing leaving you with a corrupt file.

Re: Can we delete a record from PS file using a COBOL progra

PostPosted: Mon Feb 17, 2014 5:03 pm
by ashwin1990
Thanks for the reply :)

Re: Can we delete a record from PS file using a COBOL progra

PostPosted: Mon Feb 17, 2014 5:07 pm
by NicC
Of course you can always drop the record(s) using your sort product but the same applies - read existing and create new.