Page 1 of 1

replacing the field on file 1 with the value from file2

PostPosted: Thu Jul 14, 2016 12:12 am
by Xatikva
I have two files fixed blocked, the same layout, 54 bytes. Need to replace the value of the last 5 bytes in file 1 with the value from the file 2 (last 5 bytes) if the match on the key (first 21 bytes on both files) is found. Any suggestions how to do it with the Sort or icetool ? Thank you

Re: replacing the field on file 1 with the value from file2

PostPosted: Thu Jul 14, 2016 1:01 am
by BillyBoyo
A simple JOINKEYS. Loads of examples here.

Re: replacing the field on file 1 with the value from file2

PostPosted: Fri Jul 15, 2016 2:57 am
by Magesh23586
Assuming both the files are in sort order (1,21), If it is not then remove SORTED,NOSEQCK

Untested


//S1   EXEC  PGM=SORT                                        
//SYSOUT DD SYSOUT=*                                          
//SORTJNF1 DD DSN=...FB/54                                    
//SORTJNF2 DD DSN=...FB/54                                    
//SORTOUT DD DSN=OUTFILE.OUT,                                
//           DISP=(,CATLG,DELETE),                            
//           SPACE=(CYL,(20,20),RLSE)                        
//SYSIN    DD *                                              
  OPTION COPY                                                
  JOINKEYS FILE=F1,FIELDS=(1,21,A),SORTED,NOSEQCK            
  JOINKEYS FILE=F2,FIELDS=(1,21,A),SORTED,NOSEQCK            
  REFORMAT FIELDS=(F1:1,54,F2:50,5,?)                        
  JOIN UNPAIRED,F1                                            
  OUTFIL IFTHEN=(WHEN=(60,1,CH,EQ,C'B'),OVERLAY=(50:55,5)),  
         IFOUTLEN=54                                          
 


Thanks
Magesh

Re: replacing the field on file 1 with the value from file2

PostPosted: Fri Jul 15, 2016 3:19 am
by Magesh23586
You may use OUTREC instead of OUTFIL, which will be more efficient.

Re: replacing the field on file 1 with the value from file2

PostPosted: Fri Jul 15, 2016 8:00 pm
by Xatikva
Thank you all for the replies, I figured it out, and all the comments helped