Page 1 of 1

How can i delete records form a VSAM file.

Posted: Thu Mar 19, 2009 4:01 pm
by anilanju
Hi

I have a VSAM file, and i want to delete a record from it.

i don have File Aid.

Please tell me how can i do it.

Is there is any method to delete all the records of a VSAM without
deleting the VSAM..

Regards
Anu

Posted: Thu Mar 19, 2009 4:14 pm
by Dr_Halo
Have you tried to use REPRO with a dummy file?

Posted: Thu Mar 19, 2009 4:25 pm
by anilanju
Hi

Ya i tried one method, i copied d data to a seq file, thn delete it.

But then how can i copy it back to the VSAM.

As the data is already there in d file.

Is there any method i can empty the VSAM without deleting it.

Thanks

Anju

Posted: Thu Mar 19, 2009 4:38 pm
by Dr_Halo
You can use these statements:

Code: Select all

//RECOPY   EXEC PGM=IDCAMS                             
//**********************************************************************
//INFILE   DD DSN=DSN.OF.YOUR.FILE,DISP=SHR
//VSAMFILE DD DSN=DSN.OF.YOUR.VSAM,DISP=SHR           
//SYSPRINT DD SYSOUT=*                                       
//SYSUDUMP DD SYSOU=*                                       
//SYSIN    DD * 
   REPRO INFILE(INFILE) -     
         OUTFILE(VSAMFILE)     
//  

Posted: Thu Mar 19, 2009 4:47 pm
by anilanju
Hi

It gave me this error:
IDC3308I ** DUPLICATE RECORD - KEY FOLLOWS:

as the data is already in the VSAM.
I have deleted one record after copying it to a seq file an now i want to
copy this data into Vsam removign the old data..

Thanks
Anju

Posted: Thu Mar 19, 2009 5:46 pm
by Dr_Halo
You have to delete and then to define your vsam, after doing this you can use the statement that i posted before.
Is this VSAM accessible by CICS? If yes you can use CECI to delete the record you want.

Posted: Thu Mar 26, 2009 5:47 pm
by anilanju
Hi

No i dont have access to CICS.
Is there no other method to empty the VSAM than to delete it and redife it.

As this is not always possible to delete the VSAM

Regards

Anju

Posted: Thu Mar 26, 2009 6:31 pm
by MrSpock
You should be able to do this with your SORT product. My suggestion is that you post this to the SORT forum, indicating which product you use (DFSORT or SYNCSORT) and any relevant details on the release level, etc., and providing as much details as possible about the dataset.

vsam cluster REPRO REUSE option

Posted: Thu Mar 26, 2009 10:07 pm
by Natarajan
If you want to delete all the records in VSAM without deleting VSAM. Use following methods.

method 1) Use COBOL program to do this.

method 2) Define your VSAM file with REUSE option YES.
after that everytime you want to empty the the VSAM file. Use IDCAMS REPRO with REUSE option to copy empty file to VSAM file.

method 3) it is very similar to what is explained in method 2.
If your VSAM file already defined with RESUE option NO. Use ALTER command to make VSAM file reusable and use IDCAMS REPRO with REUSE option to copy empty file to VSAM file.


If required, you can ALTER back VSAM file to NOREUSE.

Posted: Fri Mar 27, 2009 2:38 pm
by anilanju
Hi

Thanks a lot. It solved my purpose.

Thank you so much

Regards
Anju