SYNSORT compare 2 files & copy retaining the sequence



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

SYNSORT compare 2 files & copy retaining the sequence

Postby RonaldCDcosta » Wed Mar 24, 2010 5:21 am

Hi,
I need to compare 2 files mentioned below and create 3rd file with dataset information same as file1.
File 1: length 266, field to compare with file 2 = 13:5
File 2: length 675, field to compare with file 1 = 16:5

Once match is found, copy data from file 2, position (60:7) and paste to corresponding record in file 1 at position 328:7. rest all fields same as file 1.
For unmatched records, copy entire data as it is.

The challenge here is, file 1 is unsorted and we want output also in unsorted format. i.e ,out file must be similar to file 1. Only for matching records, the corresponding value must be copied from file2.

Can this be done using SORT or we will need COBOL program?
RonaldCDcosta
 
Posts: 14
Joined: Thu Feb 11, 2010 1:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: SYNSORT compare 2 files & copy retaining the sequence

Postby Alissa Margulies » Wed Mar 24, 2010 9:12 pm

Try the following SyncSort for z/OS job:
//STEP1 EXEC PGM=SORT                     
//SORTIN  DD DSN=FILE1                     (FB/266)                     
//SORTOUT DD DSN=&&TEMP,DISP=(NEW,PASS)    (FB/274)
//SYSOUT  DD SYSOUT=*                     
//SYSIN   DD *                           
  SORT FIELDS=COPY                       
  OUTREC BUILD=(1,266,267:SEQNUM,8,ZD)     
//STEP2  EXEC PGM=SORT                   
//SORTJNF1 DD DSN=&&TEMP,DISP=(OLD,DELETE) (FB/274)
//SORTJNF2 DD DSN=FILE2                    (FB/675)                                                 
//SORTOUT  DD SYSOUT=*                   
//SYSOUT   DD SYSOUT=*                   
//SYSIN    DD    *                       
  JOINKEYS FILES=F1,FIELDS=(13,5,A)       
  JOINKEYS FILES=F2,FIELDS=(16,5,A) 
  JOIN UNPAIRED,F1     
  REFORMAT FIELDS=(F1:1,274,F2:328,7)               
  SORT FIELDS=(267,8,CH,A)                 
  OUTREC IFTHEN=(WHEN=(275,1,CH,EQ,C' '),BUILD=(1,266)),
         IFTHEN=(WHEN=(275,1,CH,NE,C' '),BUILD=(1,59,275,7,67,200))
/*         
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: SYNSORT compare 2 files & copy retaining the sequence

Postby lal » Wed Mar 24, 2010 10:07 pm

Slight correction to STEP2. The JOIN statment has to be added to get the required results.
JOIN UNPAIRED,F1


Thanks,
lal
lal
 
Posts: 24
Joined: Thu Aug 13, 2009 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SYNSORT compare 2 files & copy retaining the sequence

Postby Alissa Margulies » Wed Mar 24, 2010 10:31 pm

You are correct - COPY and PASTE error. Thank you for catching that. I'll update the previous post to reflect the correction.
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: SYNSORT compare 2 files & copy retaining the sequence

Postby RonaldCDcosta » Fri Mar 26, 2010 7:45 am

Spool message:
JOINKEYS REFORMAT RECORD LENGTH= 281, TYPE = F
OUTREC RECORD LENGTH = 281
SORTOUT : RECFM=FB ; LRECL= 266; BLKSIZE= 27930
SORTOUT HAS INCOMPATIBLE LRECL


Looks like this sort creates file of reclength 281. Whereas the file needs to be of 266. How to handle this?
RonaldCDcosta
 
Posts: 14
Joined: Thu Feb 11, 2010 1:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: SYNSORT compare 2 files & copy retaining the sequence

Postby Alissa Margulies » Fri Mar 26, 2010 9:30 pm

Try replacing the OUTREC statement in the second sort step with this and let me know what your results are:

 OUTREC IFTHEN=(WHEN=(275,1,CH,EQ,C' '),BUILD=(1,266)),
       IFTHEN=(WHEN=NONE,BUILD=(1,59,275,7,67,200))
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post