How can i delete records form a VSAM file.

Post your questions related to VSAM

Moderator: Moderator Group

Post Reply
User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

How can i delete records form a VSAM file.

Post by anilanju » Thu Mar 19, 2009 4:01 pm

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

Dr_Halo
Member
Posts: 7
Joined: Wed Mar 18, 2009 5:31 pm
Location: Italy

Post by Dr_Halo » Thu Mar 19, 2009 4:14 pm

Have you tried to use REPRO with a dummy file?

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Thu Mar 19, 2009 4:25 pm

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

Dr_Halo
Member
Posts: 7
Joined: Wed Mar 18, 2009 5:31 pm
Location: Italy

Post by Dr_Halo » Thu Mar 19, 2009 4:38 pm

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)     
//  

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Thu Mar 19, 2009 4:47 pm

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

Dr_Halo
Member
Posts: 7
Joined: Wed Mar 18, 2009 5:31 pm
Location: Italy

Post by Dr_Halo » Thu Mar 19, 2009 5:46 pm

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.

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Thu Mar 26, 2009 5:47 pm

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

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Thu Mar 26, 2009 6:31 pm

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.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

vsam cluster REPRO REUSE option

Post by Natarajan » Thu Mar 26, 2009 10:07 pm

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.
Natarajan
Chennai

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Fri Mar 27, 2009 2:38 pm

Hi

Thanks a lot. It solved my purpose.

Thank you so much

Regards
Anju

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others