Page 1 of 2

Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Sun Jan 03, 2010 11:06 am
by nrvedula
Suppose there are 2 Input files A & B. Below are the records in the Input files

File A
-------
Record-1
Record-2
Record-3
Record-4

File B
------
Record-5
Record-6
Record-7
Record-8


The O/P in the Single Output file C should be as below.

File C
-------
Record-1
Record-5
Record-2
Record-6
Record-3
Record-7
Record-4
Record-8

How can we do this? Please let me know.


Regards,
Nageshwar

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Mon Jan 04, 2010 6:20 am
by dick scherrer
Hello and welcome to the forum,

To do what you want, you will use some utility - which one do you want to use?

No, this cannot be done with "a JCL" - because jcl does nothing except execute programs (many of which are utlities).

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Mon Jan 04, 2010 7:10 am
by nrvedula
I want to do using SORT Utility.

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Mon Jan 04, 2010 9:42 am
by dick scherrer
Hello,

Which sort product is being used? There are separate parts of the forum for DFSORT and Syncsort.

When you post which is being used, your topic will be moved to the appropriate part of the forum.

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Mon Jan 04, 2010 9:47 am
by nrvedula
DFSORT pls

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Mon Jan 04, 2010 10:41 pm
by Frank Yaeger
I need some more information before I can show you how to do this.

What is the RECFM and LRECL of each input file?

Please run this DFSORT job and show me the //SYSOUT messages so I can see what level you're at:

//S1    EXEC  PGM=SORT           
//SYSOUT    DD  SYSOUT=*         
//SORTIN DD *                   
RECORD                           
//SORTOUT DD DUMMY               
//SYSIN    DD    *               
  OPTION COPY                   
/*

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Tue Jan 05, 2010 3:01 pm
by upendra_water
Hello Frank, I am curious to know if this can be achieved in less than 3 steps :D
I think this is feasable in 3 steps by using SEQNUM syntax ;)

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Tue Jan 05, 2010 10:35 pm
by nrvedula
RECFM is FB and LRECL is 80 for all the files (Input & Output)

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Tue Jan 05, 2010 10:44 pm
by Frank Yaeger
It can be done in one pass (step) using a DFSORT JOINKEYS job like the following (I assumed the input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes):

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//IN1 DD *
Record-1
Record-2
Record-3
Record-4
//IN2 DD *
Record-5
Record-6
Record-7
Record-8
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  JOINKEYS F1=IN1,FIELDS=(81,8,A),SORTED,NOSEQCK
  JOINKEYS F2=IN2,FIELDS=(81,8,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,80,F2:1,80)
  OPTION COPY
  OUTFIL BUILD=(1,80,/,81,80)
//JNF1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
//JNF2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
/*


The Nov, 2009 DFSORT PTF must be installed in order for JOINKEYS to be used.

It can also be done in 3 passes (one ICETOOL step) without using JOINKEYS.

Re: Copy Alternate Records from 2 Input files in to the Single O

PostPosted: Wed Jan 06, 2010 3:10 pm
by upendra_water
Hi Frank, thank you for this sortcard.
Doing it in single step is really Great. It's really amazing. :o
Can you please provide more information Nov, 2009 DFSORT PTF software,because when I tried above syntax the job is getting abended.