Page 1 of 1

SYNCSORT to compare 2 files and overlay a field

PostPosted: Sat Feb 13, 2010 5:09 am
by RonaldCDcosta
I have 2 files:
File 1: Length 300.
first 2 digits - 00 or 10 or 20.

File2: Length 80.

I need to compare field of 15 lenght from File1 (3:15) with File2 (1:15). And only for records in file 1 having 1st two digits as '20' and if 15 digit match found in both files, than replace 20th position of file1 with 'Y'.
Can you please provide a SYNCSORT?

Re: SYNCSORT to compare 2 files and overlay a field

PostPosted: Mon Feb 15, 2010 8:21 pm
by Alissa Margulies
Please specify which records you want included in the output (matched only, matched and unmatched from File1, etc.).

Re: SYNCSORT to compare 2 files and overlay a field

PostPosted: Tue Feb 16, 2010 2:19 am
by RonaldCDcosta
The output file is same File1 with all the records in it. Just for matching records the 20th position will be updated to 'Y'
All the unmatched records need to be copied as it is with no change.

Re: SYNCSORT to compare 2 files and overlay a field

PostPosted: Tue Feb 16, 2010 10:19 pm
by Alissa Margulies
Here is a SyncSort for z/OS job that should produce your requested output:
//STEP1  EXEC PGM=SORT                                       
//SORTJNF1 DD DISP=SHR,DSN=INPUT.FILE1                       
//SORTJNF2 DD DISP=SHR,DSN=INPUT.FILE2                       
//SORTOUT  DD DSN=OUTPUT.FILE                                 
//SYSOUT   DD SYSOUT=*                                       
//SYSIN    DD *                                               
  JOINKEYS FILES=F1,FIELDS=(3,15,A)                           
  JOINKEYS FILES=F2,FIELDS=(1,15,A)                           
  JOIN UNPAIRED,F1                                           
  REFORMAT FIELDS=(F1:1,300,F2:1,1),FILL=(X'FF')             
  SORT FIELDS=COPY                                           
  OUTREC IFTHEN=(WHEN=(1,2,CH,EQ,C'20',AND,301,1,BI,NE,X'FF'),
   BUILD=(1,19,C'Y',21,280)),                                 
   IFTHEN=(WHEN=(NONE),                                       
   BUILD=(1,300))         
/*