|
View previous topic :: View next topic
|
| Author |
Message |
murali.andaluri
New User
Joined: 07 Jun 2013 Posts: 23 Location: USA
|
|
|
|
Hi,
I have a requirement where I have to read two input files and write into output file as a single record. Below is the example.
Please help me to write this using SORT utilities
File1:
AAAAA
BBBBB
CCCCC
File2:
11111
22222
33333
My output should be as below:
AAAAA11111
BBBBB22222
CCCCC33333 |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
the solution has been asked and provided may times, search the forum
JOINKEYS is the buzzword |
|
| Back to top |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
| murali.andaluri wrote: |
Hi,
I have a requirement where I have to read two input files and write into output file as a single record. Below is the example.
Please help me to write this using SORT utilities
File1:
AAAAA
BBBBB
CCCCC
File2:
11111
22222
33333
My output should be as below:
AAAAA11111
BBBBB22222
CCCCC33333 |
Assuming record length is 80
here is the code.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
AAAAA
BBBBB
CCCCC
//INB DD *
11111
22222
33333
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,8,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,8,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,5,F2:1,5)
//*
//JNF2CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
//*
//JNF1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
//*
|
|
|
| Back to top |
|
 |
murali.andaluri
New User
Joined: 07 Jun 2013 Posts: 23 Location: USA
|
|
|
|
I am uisng below code from one of the post, but it is creating empty output file. someone can help me where i am wrong?
//STEP0001 EXEC PGM=SORT
//SORTJNF1 DD DSN=MURALI.JOIN.TEST1,DISP=SHR
//SORTJNF2 DD DSN=MURALI.JOIN.TEST2,DISP=SHR
//SORTOUT DD DSN=MURALI.JOIN.OUTPUT,
// DISP=(,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=221,BLKSIZE=0),
// DSORG=PS
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,20,A)
JOINKEYS FILE=F2,FIELDS=(1,200,A)
REFORMAT FIELDS=(F1:1,20,F2:1,200)
OPTION COPY
OUTFIL FNAMES=SORTOUT,BUILD=(1,20,C',',21,200)
/* |
|
| Back to top |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
| murali.andaluri wrote: |
I am uisng below code from one of the post, but it is creating empty output file. someone can help me where i am wrong?
|
did you check my code ?
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,20,A)
JOINKEYS FILE=F2,FIELDS=(1,200,A)
|
You are comparing 1,20(offset,length) from file1 with 1,200(offset,length) from file2, which will never gonna match.
Look at my code, i have built a sequence number for eachrecord in both files
| Code: |
INREC OVERLAY=(81:SEQNUM,8,ZD)
|
Then I am comparing records in JOINKEYS.
Try to understand the significance of each keyword and functions in the code by referring dfsort application programming guide. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| magesh23586 wrote: |
Then I am comparing records in JOINKEYS.
Try to understand the significance of each keyword and functions in the code by referring dfsort application programming guide. |
Re: Significance of each keyword and function.
Your own terminology is also misleading. You do not compare the records in JOINKEYS, but you are joining records on their key fields |
|
| Back to top |
|
 |
murali.andaluri
New User
Joined: 07 Jun 2013 Posts: 23 Location: USA
|
|
|
|
| Thank you so much Magesh!!! your code is working. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|