Page 1 of 1

Merging of VSAM files

PostPosted: Thu Aug 19, 2010 2:23 pm
by ajuatsgp
Can I merge two VSAM files? These files can have duplicates. I Can copy the vsam files to two sequentials files merge them with SUM FIELDS=NONE, then copy the output seq file to a VSAM file.

But Can I merge the two VSAM files in one single step?

Re: Merging of VSAM files

PostPosted: Thu Aug 19, 2010 2:45 pm
by MrSpock
According to the DFSORT Application Programming Guide comments for Merging Records:

1.8.2 Merging Records

Input to a merge application can be up to 100 blocked or unblocked QSAM or VSAM data sets containing fixed- or variable-length records. The input data sets can be either QSAM or VSAM, but not both. The records in all input data sets must already be sorted in the same order as that required for output.

Output from a merge application can be blocked or unblocked QSAM or VSAM data sets, regardless of whether the input is QSAM or VSAM. Unless OUTFIL is used to convert variable input to fixed output, or fixed output to variable output, an output data set must be the same type (fixed or variable) as the input data set.

Re: Merging of VSAM files

PostPosted: Thu Aug 19, 2010 10:31 pm
by Frank Yaeger
ajuatsgp,

If each VSAM file is already sorted by the same key(s), you can use a DFSORT MERGE application to merge them like so:

//MRG EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SORTIN01 DD DSN=...  VSAM input file1 (sorted)
//SORTIN02 DD DSN=...  VSAM input file2 (sorted)                                                   
//SORTOUT DD DSN=...   VSAM output file
//SYSIN DD *                                                     
  RECORD TYPE=F
  OPTION EQUALS
  MERGE FIELDS=(...)
  SUM FIELDS=NONE
/*             


I'm assuming you can treat each VSAM file as fixed-length. If not, you'd need to use RECORD TYPE=V and add 4 to the starting position of the MERGE field.

Re: Merging of VSAM files

PostPosted: Fri Aug 20, 2010 1:06 pm
by ajuatsgp
Hi,

what about the duplicates records.Will they be handeled???

Re: Merging of VSAM files

PostPosted: Fri Aug 20, 2010 8:52 pm
by Frank Yaeger
Oh, I forgot you wanted that. To eliminate duplicates, add:

   SUM FIELDS=NONE


I changed the job above to include that and OPTION EQUALS.

Re: Merging of VSAM files

PostPosted: Thu Oct 07, 2010 8:53 pm
by cvrupesh
I believe one can use ELIMIT(200) in IDCAMS itself if you know the approximate duplicate counts.

Re: Merging of VSAM files

PostPosted: Thu Oct 07, 2010 8:54 pm
by cvrupesh
In the example I have given by specifying ELIMIT(200) your IDCAMS can ignore as far as you have 199 duplicates and copy the data to output.

Re: Merging of VSAM files

PostPosted: Thu Oct 07, 2010 9:08 pm
by NicC
How about the merging though?

Re: Merging of VSAM files

PostPosted: Tue Oct 12, 2010 3:40 pm
by cvrupesh
I hope once duplicates are eliminated, merging should not be a challenge. I just thought to reminding usage of ELIMIT in VSAM's.

Re: Merging of VSAM files

PostPosted: Tue Oct 12, 2010 11:18 pm
by dick scherrer
Hello,

Please do not post IDCAMS suggestions in the DFSORT part of the forum. . .