Page 1 of 1

Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 5:56 pm
by Farhaan4mf
Hi,
My shop is using FLASHCPY to take snap of entire VSAM file.
Now, My requirement is to perform a step that will copy selective records ( say from logical record# 10 to 100 or first 1000 logical records) from a VSAM file to another VSAM file. Is It possible using FLASHCPY. I am providing below code to show how our shop currently using FLASHCPY to snap entire VSAM file to another

//STEP2V2  EXEC FLASHCPY                       
//SYSTERM  DD SYSOUT=*                         
//SYSPRINT DD SYSOUT=*                         
//SYSIN    DD *                                 
   COPY DATASET(                       -       
   INCLUDE(&FRMNAME2)) -                       
   RENAMEU((&FRMNAME2, -                       
            &HLQ..&SYSUID..XMIT.VSAM2)) -       
   ALLDATA(*)                                 -
   ALLEXCP                                    -
   SPHERE                                     -
   STORCLAS(SCSHIJ)                           -
   TGTALLOC(SRC)                              -
   VOLCOUNT(ANY)                              -
   TOL(ENQF)                                  -
   REPLACEU                                   -
   CANCELERROR                                 


&HLQ..&SYSUID..XMIT.VSAM2 is the target VSAM and &FRMNAME2 is the input VSAM.
I am wondering if there is any parameter where I can specify no.of records or (startrec and endrec values) to copy only few records. Please help

Re: Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 8:04 pm
by dick scherrer
Hello,

I'm not sure about FLASHCOPY, but you can probably do what you want with your SORT product.

Re: Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 8:32 pm
by Farhaan4mf
STOPAFT or STARTREC ENDREC that we use in DFSORT will work for VSAM files also ?
If so, how are going to establish the attributes of output file ?
For flat file, we use SORTIN SORTOUT and in DCB we use DCB=*.SORTIN.
Why I am asking this is, I never used sort on VSAM files. My input & Output files both are VSAM. Output VSAM file should have exactly same features (I mean definition) as Input VSAM file has. Please give me idea for the code.

Re: Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 9:20 pm
by BillyBoyo
Don't use DCB=*.SORTIN. SORT by defualt gives you the DCB of the SORTIN, but is clever enough to know if your then extend/contract records in the Control Cards.

Your VSAM file will have to exist, so as long as you define it the same as the SORTIN VSAM, you shouldn't get a problem.

Re: Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 9:24 pm
by dick scherrer
Hello,

The DELETE/DEFINE for the original file should be available on the system. Copy this to a new DELETE/DEFINE and change the dataset names, run the IDCAMS, and you should be good to go.

Re: Copying selective records from VSAM to VSAM

PostPosted: Mon Nov 18, 2013 9:59 pm
by halfteck
You can also use IDCAMS REPRO utilising SKIP(nnn) COUNT(nnn). Or if KSDS fromkey(key) tokey(key) will give you a range of records