Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Read two inputs and write into output in a single record

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

New User


Joined: 07 Jun 2013
Posts: 11
Location: USA

PostPosted: Wed Jul 26, 2017 7:35 pm    Post subject: Read two inputs and write into output in a single record
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10292
Location: italy

PostPosted: Wed Jul 26, 2017 8:02 pm    Post subject: Reply to: Read two inputs and write into output in a single record
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: 170
Location: Chennai

PostPosted: Wed Jul 26, 2017 8:29 pm    Post subject: Re: Read two inputs and write into output in a single record
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: 11
Location: USA

PostPosted: Wed Jul 26, 2017 8:46 pm    Post subject: Reply to: Read two inputs and write into output in a single record
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: 170
Location: Chennai

PostPosted: Wed Jul 26, 2017 9:08 pm    Post subject: Re: Reply to: Read two inputs and write into output in a single record
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

Active User


Joined: 29 Apr 2008
Posts: 128
Location: Maryland

PostPosted: Thu Jul 27, 2017 1:33 am    Post subject: Re: Reply to: Read two inputs and write into output in a single record
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: 11
Location: USA

PostPosted: Thu Jul 27, 2017 6:25 pm    Post subject: Reply to: Read two inputs and write into output in a single record
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 10 Fri Aug 18, 2017 10:50 am
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us