SYNCSORT to compare 2 files and overlay a field



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

SYNCSORT to compare 2 files and overlay a field

Postby RonaldCDcosta » Sat Feb 13, 2010 5:09 am

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?
RonaldCDcosta
 
Posts: 14
Joined: Thu Feb 11, 2010 1:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: SYNCSORT to compare 2 files and overlay a field

Postby Alissa Margulies » Mon Feb 15, 2010 8:21 pm

Please specify which records you want included in the output (matched only, matched and unmatched from File1, etc.).
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: SYNCSORT to compare 2 files and overlay a field

Postby RonaldCDcosta » Tue Feb 16, 2010 2:19 am

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.
RonaldCDcosta
 
Posts: 14
Joined: Thu Feb 11, 2010 1:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: SYNCSORT to compare 2 files and overlay a field

Postby Alissa Margulies » Tue Feb 16, 2010 10:19 pm

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))         
/*
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