IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Read two inputs and write into output in a single record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
murali.andaluri

New User


Joined: 07 Jun 2013
Posts: 23
Location: USA

PostPosted: Wed Jul 26, 2017 7:35 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jul 26, 2017 8:02 pm
Reply with quote

the solution has been asked and provided may times, search the forum
JOINKEYS is the buzzword
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 26, 2017 8:29 pm
Reply with quote

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
View user's profile Send private message
murali.andaluri

New User


Joined: 07 Jun 2013
Posts: 23
Location: USA

PostPosted: Wed Jul 26, 2017 8:46 pm
Reply with quote

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
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Wed Jul 26, 2017 9:08 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Thu Jul 27, 2017 1:33 am
Reply with quote

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
View user's profile Send private message
murali.andaluri

New User


Joined: 07 Jun 2013
Posts: 23
Location: USA

PostPosted: Thu Jul 27, 2017 6:25 pm
Reply with quote

Thank you so much Magesh!!! your code is working.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top