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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby ashwin1990 » Mon Feb 17, 2014 4:42 pm

Can we delete a record from PS file using a COBOL program?
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: 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

Postby NicC » Mon Feb 17, 2014 4:44 pm

Yes - read the file and create a new file with only the records that you want. Think about it.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

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

Postby ashwin1990 » Mon Feb 17, 2014 4:46 pm

Can we use 'DELETE RECORD' command in the COBOL program for PS file. This will save me from creating a new file?
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Mon Feb 17, 2014 4:54 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

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

Postby ashwin1990 » Mon Feb 17, 2014 5:03 pm

Thanks for the reply :)
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Mon Feb 17, 2014 5:07 pm

Of course you can always drop the record(s) using your sort product but the same applies - read existing and create new.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post