Compare 2 files and write O/P accordingly



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Compare 2 files and write O/P accordingly

Postby gracemanoj » Mon Aug 31, 2009 11:07 pm

I have a requirement in which I have to compare today's and previous day's file.

The file LRECL is 479

If the record is new in today's file then I need to write to a output file of the same LRECL with a CODE 'A' in the 470th position. If a record in previous day's file is not present then I need to write to the same output file with the CODE 'D' in the 470th position. Also if the record in previous day's file of the same key doesn't match with the record in today's file then the output file should be written with the Code 'C' in 470th position.

There will be no duplicates in the file. Also the keys will be the first 38 bytes

Please let me know if we can write an ICETOOL for this

Thanks in advance
gracemanoj
 
Posts: 7
Joined: Mon Aug 31, 2009 11:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare 2 files and write O/P accordingly

Postby skolusu » Tue Sep 01, 2009 1:38 am

The following DFSORT/ICETOOL JCL will give you the desired results
                                         
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DUMMY,DCB=(LRECL=479,RECFM=FB,BLKSIZE=27782)           
//SORTOUT  DD DSN=&&H,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)           
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  OUTFIL REMOVECC,HEADER1=(C'HDR',479:X)                             
//STEP0200 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT           
//         DD DSN=your PREV day FB 479 Lrecl file,DISP=SHR
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT           
//         DD DSN=your CURR day FB 479 Lrecl file,DISP=SHR
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                     
  SPLICE FROM(IN) TO(OUT) ON(1,38,CH) WITH(1,479) WITH(481,1) -     
  KEEPNODUPS USING(CTL1)                                             
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(480:ID=2)),
  IFTHEN=(WHEN=(480,2,ZD,EQ,1),OVERLAY=(480:C'11',39,441)),         
  IFTHEN=(WHEN=(480,2,ZD,EQ,2),OVERLAY=(480:C'22'))                 
                                                                     
  OUTFIL FNAMES=OUT,IFOUTLEN=479,OMIT=(480,2,ZD,EQ,12,AND,           
  (39,256,CH,EQ,482,256,CH,AND,296,184,CH,EQ,739,184,CH)),           
  IFTHEN=(WHEN=(480,2,ZD,EQ,11),OVERLAY=(470:C'D')),                 
  IFTHEN=(WHEN=(480,2,ZD,EQ,12),OVERLAY=(470:C'C')),                 
  IFTHEN=(WHEN=(480,2,ZD,EQ,22),OVERLAY=(470:C'A'))                 
/*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Compare 2 files and write O/P accordingly

Postby gracemanoj » Tue Sep 01, 2009 10:49 am

Thanks. I'll try the code.
Is there a way to display in the sysout the number of records added, deleted and changed ?
gracemanoj
 
Posts: 7
Joined: Mon Aug 31, 2009 11:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare 2 files and write O/P accordingly

Postby gracemanoj » Thu Sep 03, 2009 3:17 pm

Getting a syntax error. Below is the DFSMSG

CTL1CNTL :
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(480:ID=2)),
*
IFTHEN=(WHEN=(480,2,ZD,EQ,1),OVERLAY=(480:C'11',39,441)),
IFTHEN=(WHEN=(480,2,ZD,EQ,2),OVERLAY=(480:C'22'))

OUTFIL FNAMES=OUT,IFOUTLEN=479,OMIT=(480,2,ZD,EQ,12,AND,
(39,256,CH,EQ,482,256,CH,AND,296,184,CH,EQ,739,184,CH)),
IFTHEN=(WHEN=(480,2,ZD,EQ,11),OVERLAY=(470:C'D')),
IFTHEN=(WHEN=(480,2,ZD,EQ,12),OVERLAY=(470:C'C')),
IFTHEN=(WHEN=(480,2,ZD,EQ,22),OVERLAY=(470:C'A'))
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
gracemanoj
 
Posts: 7
Joined: Mon Aug 31, 2009 11:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare 2 files and write O/P accordingly

Postby Frank Yaeger » Thu Sep 03, 2009 9:17 pm

The job runs fine with DFSORT. However, the WER messages indicate you're using Syncsort, not DFSORT. Kolusu and I are DFSORT developers. DFSORT and Syncsort are competitive products. We're happy to answer questions on DFSORT and DFSORT's ICETOOL, but we
don't answer questions on Syncsort.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post