replacing the field on file 1 with the value from file2



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

replacing the field on file 1 with the value from file2

Postby Xatikva » Thu Jul 14, 2016 12:12 am

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
Xatikva
 
Posts: 2
Joined: Wed Jul 13, 2016 11:20 pm
Has thanked: 2 times
Been thanked: 0 time

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

Postby BillyBoyo » Thu Jul 14, 2016 1:01 am

A simple JOINKEYS. Loads of examples here.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby Magesh23586 » Fri Jul 15, 2016 2:57 am

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

These users thanked the author Magesh23586 for the post:
Xatikva (Fri Jul 15, 2016 8:01 pm)
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

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

Postby Magesh23586 » Fri Jul 15, 2016 3:19 am

You may use OUTREC instead of OUTFIL, which will be more efficient.

These users thanked the author Magesh23586 for the post:
Xatikva (Fri Jul 15, 2016 8:01 pm)
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

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

Postby Xatikva » Fri Jul 15, 2016 8:00 pm

Thank you all for the replies, I figured it out, and all the comments helped
Xatikva
 
Posts: 2
Joined: Wed Jul 13, 2016 11:20 pm
Has thanked: 2 times
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post