mail_ssb
New User
Joined: 26 Mar 2005 Posts: 17
|
|
|
|
Hello,
I need to empty data from VSAM dataset (KSDS/ESDS), keeping the structure of VSAM intact.
One option is Delete and then Redefine. Is there any other way of doing this...? Following works for PS datasets, but I have problem in using this with VSAM:
DD1 DD DSN=MY.VSAM1,DISP=SHR
DD2 DD DSN=MY.VSAM1,DISP=SHR
SORT FIELDS=COPY
OMIT COND=ALL
(Appropriate symbols and syntax is assumed in above JCL statements)
Appreciate your guidance and attention. |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MY.VSAM1,DISP=SHR
//SORTOUT DD DSN=MY.VSAM1,DISP=SHR
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=ALL
/*
|
This won't work, because you can't do a COPY using the same VSAM data set as input and output.
You can do a SORT using the same VSAM data set as input and output, but you also need to use DFSORT's VSAMIO option which:
Quote: |
specifies that DFSORT can use the same VSAM data set for input and output when all of the following conditions are met:
o The application is a sort
o RESET is in effect
o The VSAM data set was defined with REUSE
These conditions ensure that the VSAM data set is processed as NEW for output and will contain the sorted input records, that is, it will be sorted in-place.
DFSORT terminates if the same VSAM data set is specified for input and output and any of the above conditions are not met.
|
So if your VSAM data set was defined with REUSE, something like this might work:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MY.VSAM1,DISP=SHR
//SORTOUT DD DSN=MY.VSAM1,DISP=SHR
//SYSIN DD *
OPTION VSAMIO,RESET
OMIT COND=ALL
SORT FIELDS=(p,m,BI,A)
/*
|
where p is the starting position of the key and m is the length of the key (since you're deleting all of the records, it probably doesn't matter what you use for p and m). |
|