IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Optimizing the ICETOOL Code to compare two files


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Thu Jan 04, 2007 6:34 pm
Reply with quote

Hi ,

After comparasion of two sequential files for updating a change indicator field in the outputfile , i am using the following ICETOOL code, it's working fine.But this code seems to be lengthy ,can any body suggest how to minimise this code to minimise the response time.

REQUIREMENT:

SAME RECORD IS PRESENT IN TWO FILES SHOULD BE ELIMINATED.
BASED ON KEY FIELDS CHANGE INDICATOR WILL BE UPDATED AS ADDED,DELETED AND UPDATED.

Code:

//STEP1    EXEC PGM=ICETOOL                                           
//*                                                                   
//TOOLMSG   DD SYSOUT=*                                               
//DFSMSG    DD SYSOUT=*                                               
//IN1       DD DSN=F5748TGH.NEWFILE,DISP=SHR 
//IN2       DD DSN=F5748TGH.OLDFILE,DISP=SHR
//T1        DD DSN=&&T1,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)           
//T2        DD DSN=&&T2,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)           
//INT       DD DSN=*.T1,DISP=(OLD,PASS),VOL=REF=*.T1                 
//          DD DSN=*.T2,DISP=(OLD,PASS),VOL=REF=*.T2                 
//FILEA     DD DSN=&&NODUP,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)       
//OUT       DD SYSOUT=*                                               
//TOOLIN    DD   *                                                   
  COPY FROM(IN1) USING(CTL1)                                         
  COPY FROM(IN2) USING(CTL2)                                         
  SELECT FROM(INT) TO(FILEA) ON(1,200,CH)  NODUPS                     
  SELECT FROM(INT) TO(OUT) ON(1,200,CH)  FIRSTDUP                     
/*                                                                   
//CTL1CNTL  DD *                                                     
    OUTFIL FNAMES=T1,OUTREC=(1,200,C'1')                             
/*                                                                   
//CTL2CNTL  DD   *                                                   
    OUTFIL FNAMES=T2,OUTREC=(1,200,C'2')                             
/*                                                                   

//STEP2    EXEC PGM=SORT                                             
//SYSPRINT DD SYSOUT=A                                               
//SYSOUT   DD SYSOUT=A                                               
//SYSLIST  DD SYSOUT=A                                               
//SORTIN   DD DSN=&&NODUP,SPACE=(CYL,(5,5),RLSE),DISP=(OLD,DELETE)   
//SORTOUT  DD DSN=&&ONODUP,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)       
//SYSIN    DD *                                                     
  SORT FIELDS=(201,1,CH,A)                                           
/*                                                                   

//STEP3    EXEC PGM=ICETOOL                                           
//*                                                                   
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//INT      DD DSN=&&ONODUP,DISP=(OLD,DELETE)                           
//UPDATE   DD DSN=&&UPDATE,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)         
//DELETE   DD DSN=&&DELETE,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)         
//ADDED    DD DSN=&&ADDED,SPACE=(CYL,(5,5),RLSE),DISP=(,PASS)         
//TOOLIN   DD   *                                                     
  SORT FROM(INT) USING(CTL1)                                           
/*                                                                     
//CTL1CNTL DD   *                                                     
 SORT FIELDS=(42,12,CH,A,55,8,CH,A,76,25,CH,A,101,20,CH,A),EQUALS     
 SUM FIELDS=(201,1,ZD)                                                 
 OUTFIL FNAMES=UPDATE,INCLUDE=(201,1,ZD,EQ,3),OUTREC=(1,20,C'U',22,179)
 OUTFIL FNAMES=ADDED,INCLUDE=(201,1,CH,EQ,C'1'),                       
 OUTREC=(1,20,C'A',22,179)                                             
 OUTFIL FNAMES=DELETE,INCLUDE=(201,1,CH,EQ,C'2'),                     
 OUTREC=(1,20,C'D',22,179)                                             
/*                                                                     

//STEP4    EXEC PGM=SORT                                           
//SYSPRINT DD SYSOUT=A                                             
//SYSOUT   DD SYSOUT=A                                             
//SYSLIST  DD SYSOUT=A                                             
//SORTIN   DD DSN=&&UPDATE,DISP=(OLD,DELETE)                       
//         DD DSN=&&ADDED,DISP=(OLD,DELETE)                       
//         DD DSN=&&DELETE,DISP=(OLD,DELETE)                       
//SORTOUT  DD DSN=F5748TGH.F6410S3P.COBA.PARTA.ELIG.OUT,DISP=SHR   
//SYSIN    DD *                                                   
  SORT FIELDS=(42,12,CH,A,55,8,CH,A,76,25,CH,A,101,20,CH,A)       
/*
Back to top
View user's profile Send private message
shuklas

New User


Joined: 21 Dec 2006
Posts: 20
Location: London

PostPosted: Thu Jan 04, 2007 7:31 pm
Reply with quote

This can be done by splicing function
Example given below:

Below is an ICETOOL job that can do this match by using the SPLICE operator. SPLICE helps you perform various file join and match operations. The trick here is to add an identifier of '11' to the File1 records, add an identifier of '22' to the File2 records, and splice the second id byte for matching records so we get '12' for names in both files, '11' for names only in File1 and '22' for names only in File2.

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input File1
//IN2 DD DSN=... input File2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5))
// USE MOD FOR T1
// DISP=(MOD,PASS)
//OUT12 DD SYSOUT= names in File1 and File2
//OUT1 DD SYSOUT= names in File1 only
//OUT2 DD SYSOUT= names in File2 only
//TOOLIN DD 
* Add '11' identifier for FILE1 records.
COPY FROM(IN1) TO(T1) USING(CTL1)
 *Add '22' identifier for FILE2 records.
COPY FROM(IN2) TO(T1) USING(CTL2)
 *SPLICE to match up records and write them to their appropriate output files.
SPLICE FROM(T1) TO(OUT12) ON(1,1,CH) WITH(13,1) -
USING(CTL3) KEEPNODUPS
/*
//CTL1CNTL DD *
 Mark FILE1 records with '11'
INREC OVERLAY=(12:C'11')
/*
//CTL2CNTL DD *
 Mark FILE2 records with '22'
INREC OVERLAY=(12:C'22')
/*
//CTL3CNTL DD *
* Write matching records to OUT12 file. Remove id.
OUTFIL FNAMES=OUT12,INCLUDE=(12,2,CH,EQ,C'12'),BUILD=(1,10)
* Write FILE1 only records to OUT1 file. Remove id.
OUTFIL FNAMES=OUT1,INCLUDE=(12,2,CH,EQ,C'11'),BUILD=(1,10)
* Write FILE2 only records to OUT2 file. Remove id.
OUTFIL FNAMES=OUT2,INCLUDE=(12,2,CH,EQ,C'22'),BUILD=(1,10)
/*


So when the records are present in both the files it has '12' you put 'U' as indicator,
Present only in first '11' if this is for add 'A' and present only in secord is '22' id it is for deletion put 'D'.
Back to top
View user's profile Send private message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Thu Jan 04, 2007 7:52 pm
Reply with quote

hi ,

can you please explain how 12 will come, when we did the splice,from 11 and 22 .
Back to top
View user's profile Send private message
shuklas

New User


Joined: 21 Dec 2006
Posts: 20
Location: London

PostPosted: Thu Jan 04, 2007 8:00 pm
Reply with quote

When we do the overlay on the second digit of the combination '11' and '22'.
so if record is present in both the files it will have '12' in the record and if only in first file then '11' will remain and if only in second then '22' will remain.

I hope you got the Idea of this.
If you want to see how this is done go and change the temporary file to some output file and see the result. icon_smile.gif
That is the best way to do this.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Jan 04, 2007 8:05 pm
Reply with quote

avaneendra_linga wrote:
can you please explain how 12 will come, when we did the splice,from 11 and 22 .
Go look here, it was all discussed just the other day http://www.ibmmainframes.com/viewtopic.php?t=16806
Also, it is further explained in the great PDF Create files with matching and non-matching records[url][/url]
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compile rexx code with jcl CLIST & REXX 6
Search our Forums:

Back to Top