MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

compare two files in sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
koolspark
Beginner


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Thu May 17, 2012 8:39 am    Post subject: compare two files in sort Reply with quote

hi,

I've a specific requirement to compare two files & write into two output files.

F1: (file1 can contain duplicates)
LRECL = 400
key = (110,06,CH)

F2:(file2 doesn't contain any duplicates)
LRECL= 2414
key = (01,6,CH)

I need to compare these two files on the keys & create two output files.
output file1 should contain all the records from F1 file(both matched and unmatched). if the key doesn't match, write the record as it is in the output file1 from F1 input file and if the key match then i should format the F1 file record as follows and write to output file1(overlaying few fields in file1 from file2) .
F1:1,144,F2:242,2,F2:351,2,F2:460,2,F2:569,2,F2:29,3,F2:82,3,F1:163,236

output file2 should only contain the unmatched records from F1 file.

Thanks,
Back to top
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Thu May 17, 2012 9:23 am    Post subject: Reply with quote

koolspark,
Try below untested...

In the overlay, you can actually overlay entire 14 bytes (from file 2) but i am showing them differenly for the ease of understanding...

Code:
//STEP0001     EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                         
//SORTJNF1 DD FILE1/FB400                                     
//SORTJNF2 DD FILE2/FB2414                                     
//OUT01    DD SYSOUT=*                                         
//OUT02    DD SYSOUT=*                                         
//SYSIN    DD *                                               
  JOINKEYS FILES=F1,FIELDS=(110,06,A)                         
  JOINKEYS FILES=F2,FIELDS=(001,06,A)                         
  JOIN UNPAIRED,F1                                             
  REFORMAT FIELDS=(F1:001,400,                                 
                   F2:242,002,                                 
                   F2:351,002,                                 
                   F2:460,002,                                 
                   F2:569,002,                                 
                   F2:029,003,                                 
                   F2:082,003,?)                               
  INREC IFTHEN=(WHEN=(415,1,CH,EQ,C'B'),                       
        OVERLAY=(145:401,002,                                 
                     403,002,                                 
                     405,002,                                 
                     407,002,                                 
                     409,003,                                 
                     412,003))                                 
  SORT FIELDS=COPY                                             
  OUTFIL FNAMES=OUT01,BUILD=(1,400)                           
  OUTFIL FNAMES=OUT02,BUILD=(1,400),INCLUDE=(415,1,CH,EQ,C'1')
/*

Thanks,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group