Comparing Old and new file



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

Comparing Old and new file

Postby lal » Thu Aug 13, 2009 10:16 pm

Hi Friends,
I have 2 files old and an new file of LRECL=80, I have to compare these two files and create 2 output files where one file will have all the changes and the other file will have records that didn't changed.

FILES ARE SORTED BY 2 KEYS - FIELD1 - (POSITION 1 TO 26) & FIELD2 - (POSITION 30 TO 39)

OLD FILE:-
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
AAAAAAAAAAAAAAAAAAAAAAA100   1000000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB         
BBBBBBBBBBBBBBBBBBBBBBB100   1000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC         
CCCCCCCCCCCCCCCCCCCCCCC100   2000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
CCCCCCCCCCCCCCCCCCCCCCC200   3000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
FFFFFFFFFFFFFFFFFFFFFFF100   1000000000 111111111111111111111111111111
GGGGGGGGGGGGGGGGGGGGGGG200   1000000000 111111111111111111111111111111
******************************** Bottom of Data ********************************


NEW FILE:-
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
AAAAAAAAAAAAAAAAAAAAAAA100   1000000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB         
BBBBBBBBBBBBBBBBBBBBBBB100   3000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC         
CCCCCCCCCCCCCCCCCCCCCCC100   1000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
CCCCCCCCCCCCCCCCCCCCCCC200   4000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
DDDDDDDDDDDDDDDDDDDDDDD100   1000000000 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE         
EEEEEEEEEEEEEEEEEEEEEEE100   1000000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF         
FFFFFFFFFFFFFFFFFFFFFFF100   1000000000 222222222222222222222222222222
GGGGGGGGGGGGGGGGGGGGGGG200   1000000000 222222222222222222222222222222
******************************** Bottom of Data ********************************



Output:-
WE NEED 2 FILES, ONE FILE WITH ALL THE CHANGES AND OTHER FILE WITH UNCHANGED RECORDS


AFTER COMPARING THE PREVIOUS AND CURRENT FILES, POSTION 28 - INDICATES IF THE RECORD WAS:-
 'A' - ADDED -  IF THE NEW KEYS (KEYS ARE FIELD1 & FIELD2) HAS BEEN ADDED
 'D' - DELETED - IF THE KEYS (KEYS ARE FIELD1 & FIELD2) HAVE BEEN DELETED
 'C' - CHANGED - GET THE NEW RECORD FROM THE NEW FILE IF WE FIND CHANGES BETWEEN '41 THRU 80 COLUMNS'

FINALLY THIS FILE WILL BE SORTED BY FIELD1 AND FIELD2


FILE WITH CHANGES:-

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
BBBBBBBBBBBBBBBBBBBBBBB100 D 1000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC         
BBBBBBBBBBBBBBBBBBBBBBB100 A 3000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC         
CCCCCCCCCCCCCCCCCCCCCCC100 A 1000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
CCCCCCCCCCCCCCCCCCCCCCC100 D 2000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
CCCCCCCCCCCCCCCCCCCCCCC200 D 3000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
CCCCCCCCCCCCCCCCCCCCCCC200 A 4000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD         
DDDDDDDDDDDDDDDDDDDDDDD100 A 1000000000 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE         
EEEEEEEEEEEEEEEEEEEEEEE100 A 1000000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF         
FFFFFFFFFFFFFFFFFFFFFFF100 C 1000000000 222222222222222222222222222222
GGGGGGGGGGGGGGGGGGGGGGG200 C 1000000000 222222222222222222222222222222
******************************** Bottom of Data ********************************

FILE WITHOUT CHANGES:-

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
AAAAAAAAAAAAAAAAAAAAAAA100   1000000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB         
******************************** Bottom of Data ********************************
 


Kindly appreciate your help

Thanks for your help in advance,
Lal
lal
 
Posts: 24
Joined: Thu Aug 13, 2009 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Comparing Old and new file

Postby Alissa Margulies » Fri Aug 14, 2009 12:44 am

Try this SyncSort for z/OS JOIN application to get the desired results:
//SORT1  EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*                                             
//SORTJNF1 DD *                                                       
AAAAAAAAAAAAAAAAAAAAAAA100   1000000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBB100   1000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCC100   2000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
CCCCCCCCCCCCCCCCCCCCCCC200   3000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
FFFFFFFFFFFFFFFFFFFFFFF100   1000000000 111111111111111111111111111111
GGGGGGGGGGGGGGGGGGGGGGG200   1000000000 111111111111111111111111111111
//SORTJNF2 DD *                                                       
AAAAAAAAAAAAAAAAAAAAAAA100   1000000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBB100   3000000000 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCC100   1000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
CCCCCCCCCCCCCCCCCCCCCCC200   4000000000 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDD100   1000000000 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEE100   1000000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFF100   1000000000 222222222222222222222222222222
GGGGGGGGGGGGGGGGGGGGGGG200   1000000000 222222222222222222222222222222
//SORTOF01 DD DSN=MATCHED.RECORDS,...
//SORTOF02 DD DSN=UPDATED.RECORDS,...
//SYSIN    DD *                                                 
   JOINKEYS FILE=F1,FIELDS=(1,26,A,30,10,A)                   
   JOINKEYS FILE=F2,FIELDS=(1,26,A,30,10,A)                   
   JOIN UNPAIRED                                             
   REFORMAT FIELDS=(F1:1,80,F2:1,80)                         
   SORT FIELDS=COPY                                           
   OUTFIL FILES=01,INCLUDE=(1,80,BI,EQ,81,80,BI),BUILD=(1,80)
   OUTFIL FILES=02,SAVE,                                     
     IFTHEN=(WHEN=(1,1,CH,EQ,C' '),BUILD=(81,27,C'A',109,52)),
     IFTHEN=(WHEN=(81,1,CH,EQ,C' '),BUILD=(1,27,C'D',29,52)),
     IFTHEN=(WHEN=NONE,BUILD=(81,27,C'C',109,52))             
/*                                                           
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: Comparing Old and new file

Postby lal » Fri Aug 14, 2009 1:08 am

Hi Alissa,
It works wonderful.

Thanks a lot,

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

Re: Comparing Old and new file

Postby lal » Mon Aug 17, 2009 11:00 pm

Hi Friends,
Adding to my previous request, I need a trailer record with total number of adds, changes and deletes. Can you please guid me how can that be achieved

At the end of SORTOF02
TRAILER RECORD:0100|0020|0010


Where 0100 - records added, 0020 - records changed and 0010 - records deleted

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

Re: Comparing Old and new file

Postby lal » Tue Aug 18, 2009 12:02 am

Hi Friends,
Well, while building the SORTOF02 file, I suffixed the file at 81 thru 83 positions with '100' for added records, '010' for changed records and '001' for deleted records.

Then added the next sort step to add position 81 for adds, position 82 for changes and 83 for all deletes.

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

Re: Comparing Old and new file

Postby lal » Tue Aug 18, 2009 12:20 am

Hi Friends,
When I tried to add the trailer record as per my previous post, I got the error WER107A since I had DCB=(RECFM=FB,LRECL=80). Later I removed the DCB=(RECFM=FB,LRECL=80) parameters and output was written to the file. When I looked at the file characteristics it had LRECL=81, an additional column in the starting of the file for printing reports.

But I want a file with LRECL=80 and not 81, and I do not want to add one more sort step to convert file from LRECL 81 to 80. Is there any way I can add the trailer record in a better way.

Appreciate your help,

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

Re: Comparing Old and new file

Postby lal » Tue Aug 18, 2009 12:24 am

Hi Friends,
Well, I could have had more patience and done some research...REMOVECC parameter in TRAILER1 fixed my issue.


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

Re: Comparing Old and new file

Postby dick scherrer » Tue Aug 18, 2009 2:23 am

Good to hear it is working - thanks for letting us know :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post