IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Delete a record in a VSAM file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Sat Dec 21, 2013 1:01 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Dec 21, 2013 1:30 pm
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
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.

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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Dec 24, 2013 5:55 am
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

Moderator Emeritus


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

PostPosted: Tue Dec 24, 2013 7:08 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Dec 24, 2013 4:06 pm
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: 213
Location: Chennai

PostPosted: Fri Jan 17, 2014 8:06 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top