Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 14
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

Senior Member


Joined: 14 Mar 2007
Posts: 10492
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: 213
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: 14
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: 213
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: 340
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: 14
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 Concatenaing multiple rows to single ... Vignesh Sid DFSORT/ICETOOL 1 Tue Aug 14, 2018 8:59 am
No new posts Formating of Amount field in CLIST be... Anil Kumar Prajapati CLIST & REXX 9 Fri Aug 03, 2018 6:34 pm
No new posts Add Comma to each record until find t... naveensrimf DFSORT/ICETOOL 6 Sat Jul 28, 2018 12:25 am
No new posts Need Help to Create 4 Output Records ... satish.ms10 DFSORT/ICETOOL 5 Thu Jul 19, 2018 1:55 am
No new posts Remove duplicate record with condition rajiv rengasamy DFSORT/ICETOOL 4 Wed Jul 11, 2018 3:55 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us