|
View previous topic :: View next topic
|
| Author |
Message |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please do not post links to other forums.
This forum does not allow this.
d |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|