Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Delete a record in a VSAM file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Sat Dec 21, 2013 1:01 am    Post subject: Delete a record in a VSAM file
Reply with quote

Hi,

I need to delete a record in a VSAM file. Can we do it in sort ?

VSAM file of length 265
Key length 36

I need to delete a record starts from 2nd position of length 14 i.e(2,14)

(2,14,ch,eq,c'AAAABBBBCCCCDD').
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Sat Dec 21, 2013 1:30 pm    Post subject: Reply to: Delete a record in a VSAM file
Reply with quote

You can't delete a record from KSDS with SORT.

You can read an entire dataset and write out all but the record you don't want, but there will be more efficient ways than that, if you have been clear in what you want.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Dec 23, 2013 10:49 pm    Post subject: Reply to: Delete a record in a VSAM file
Reply with quote

If your VSAM data set defined with REUSE, then you can use VSAMIO parm so that you can use the same VSAM data set for input and output. However there are some conditions to be met. Please read upon the parm VSAMIO in the following link for a detailed explanation of the parm.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ice1ca60/3.14?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Dec 24, 2013 5:55 am    Post subject:
Reply with quote

Kolusu, I could see your 10 years old post and detailed explaination on this,


link to external forum removed


Magesh, this would hep you on what you want.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Dec 24, 2013 7:08 am    Post subject:
Reply with quote

Hello,

Please do not post links to other forums.

This forum does not allow this.

d
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Dec 24, 2013 4:06 pm    Post subject:
Reply with quote

Sure dick.

Magesh: A little Google search could give you many answers on what you have asked, here is one of the similar solution I could find ;

We first copy contents of the vsam file to a temp dataset. Now we concatenate this temp dataset along with the records to be deleted and load back to the original file.when we concate the records to be deleted file with the temp dataset, all the keys which we want to delete will be duplicates. So we use the SELECT operator with NODUPS option to eliminate all the records to be deleted. Note that the out vsam dataset is same as the input dataset. You can use the same input vsam file as output vsam file when it is defined with REUSE option

Code:
//******************************************************************
//* THIS STEP WILL DELETE RECORDS IN AN EXISTING VSAM CLUSTER      *
//******************************************************************
//STEP0300 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//VSAMIN   DD DSN=YOUR INPUT VSAM FILE,         
//            DISP=SHR                                   
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//CON      DD DSN=YOUR VSAM DELETE REC FILE,                     
//            DISP=SHR                                           
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                     
//OUT      DD DSN=YOUR INPUT VSAM FILE,         
//            DISP=OLD                                   
//TOOLIN   DD *                   
  COPY FROM(VSAMIN) TO(T1)                         
  SELECT FROM(CON) TO(OUT) ON(2,14,CH) NODUPS       
//DFSPARM  DD *                                     
  OPTION VSAMIO,RESET                               
/* 
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Jan 17, 2014 8:06 pm    Post subject: Reply to: Delete a record in a VSAM file
Reply with quote

Thanks Rohit and Kolsu, this is really awesome and useful, I actually did this in another way ,which was very lengthy process, But applicable for all VSAM
since i dont know how to find whether it is in re-use or not and in defintion of the control card it doesnt have reuse keyword

My code:
Code:

//STEP01 EXEC PGM=IDCAMS                   
//SYSPRINT DD SYSOUT=*                     
//SYSOUT DD SYSOUT=*                       
//SYSIN DD *                               
 DEF CL ( -                                 
        NAME(VSAM1) -
 ..

//STEP02 EXEC PGM=SORT,COND=(4,LT)                               
//SORTIN DD DISP=SHR,                                             
//          DSN=VSAM                           
//SORTOUT DD DSN=VSAM1,DISP=SHR               
//SYSOUT DD SYSOUT=*                                             
//SYSIN DD *                                                     
  SORT FIELDS=COPY                                               
  OMIT COND=(29,4,PD,EQ,1131219,
                AND,(33,4,PD,EQ,133114,OR,33,4,PD,EQ,134110,OR,   
                33,4,PD,EQ,134554,OR,33,4,PD,EQ,134556))         
/*                                                               
//STEP03 EXEC PGM=IDCAMS,COND=(4,LT)                 
//SYSPRINT DD SYSOUT=*                               
//SYSOUT DD SYSOUT=*                                 
//SYSIN DD *   
 DEL VSAM CL PRG                             
 DEF CL ( -                                 
        NAME(VSAM) -
...
//STEP04 EXEC PGM=SORT,COND=(4,LT)                   
//SORTIN DD DISP=SHR,                                 
//          DSN=VSAM1             
//SORTOUT DD DSN=VSAM,DISP=OLD     
//SYSOUT DD SYSOUT=*                                 
//SYSIN DD *                                         
  SORT FIELDS=COPY                                   
/*                                                   
//STEP05 EXEC PGM=IDCAMS,COND=(4,LT)           
//SYSPRINT DD SYSOUT=*                         
//SYSOUT DD SYSOUT=*                           
//SYSIN DD *                                   
  DEL VSAM1 CL PRG         
  IF MAXCC LE 8 THEN SET MAXCC = 0             
/*                                             
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts JCL to delete component in a package sundaram.naveen Compuware & Other Tools 14 Tue Nov 29, 2016 6:21 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us