Search code examples
mainframedfsortsyncsort

Compare two files and include both match and non match records


I need to merge two files into one . Suppose I have 2 input files FILE1 and FILE2. And I need to non-matching records from FILE1 and FILE2 into FILE 3 as well as I want to write matching records also into FILE3.If there is matching based on key in FILE1 and FILE2 then matching record to be written must be picked from FILE1/FILE2 on basis of some condition.

The key position in both the Input Files is same.

Can anybody please help me to write SORTCARD, how Can I get this in single step in SyncSort or DFSort??


Solution

  • I got my solution using following sort card:

        JOINKEYS F1=IN1,FIELDS=(1,7,A,13,7,A)                     
        JOINKEYS F2=IN2,FIELDS=(1,7,A,13,7,A)                     
        JOIN UNPAIRED,F1,F2                                       
        REFORMAT FIELDS=(F1:1,239,F2:1,239,?)                     
        OPTION COPY                                               
        OUTFIL FNAMES=OUT1,INCLUDE=(479,1,SS,EQ,C'1,2'),          
        IFTHEN=(WHEN=(479,1,CH,EQ,C'1'),                    
              BUILD=(1,239,479,1)),                       
        IFTHEN=(WHEN=NONE,                                  
              BUILD=(240,239,479,1))                      
        OUTFIL FNAMES=OUT2,INCLUDE=(479,1,SS,EQ,C'B'),            
        IFTHEN=(WHEN=(111,1,FS,EQ,NUM,AND,175,1,FS,EQ,NUM),
               BUILD=(1,239)),                            
        IFTHEN=(WHEN=(350,1,FS,EQ,NUM,AND,414,1,FS,EQ,NUM),
               BUILD=(240,239)),                          
        IFTHEN=(WHEN=NONE,                                 
              BUILD=(1,239))