MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem comparing 2 files and preparing a 3rd file from them

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
solitude bliss
Beginner


Joined: 16 Jan 2004
Posts: 8
Topics: 3

PostPosted: Tue Oct 03, 2006 1:43 pm    Post subject: Problem comparing 2 files and preparing a 3rd file from them Reply with quote

I am trying to compare two files and generate a file which will have the fields from them. Here is what I am trying to do

Code:
Input file 1
4095356001090132636908XXXX
3011865001090132043565XXXX


Code:
Input file 2
4095356001090133724416XXXX
3011865001090132043565XXXX


Compare these two files, Primary key 1-10. If there is a change in the field 11 to 22, then the output file should have [Primary key, Field 11 to 22 from file 1, Field 11 to 22 from file 2]

Based on the value in cols 34 to 38, I am writing two files.

Code:
Output file
4095356001090132636908090133724416ZZZA


Here is the ICETOOL job I am using. It is working perfectly fine, except for 1 record. Somehow, there is one record which is sneaking in the output file. The record is 0000273902000000000273XXXX. This is EXACTLY the same in both the input files!! Hence should not be appearing in the output file.

Code:
//**********************************************************
//JSTEP010 EXEC PGM=ICETOOL                                 
//**********************************************************
//TOOLMSG  DD  SYSOUT=*                                     
//DFSMSG   DD  SYSOUT=*                                     
//SYSUDUMP DD  SYSOUT=*                                     
//SYSOUT   DD  SYSOUT=*                                     
//TOOLIN   DD *                                             
   SORT FROM(INFILE1) TO(INTEMP1)               USING(CTL1)
   SORT FROM(INFILE2) TO(INTEMP2)               USING(CTL2)
   SORT FROM(INTEMP)                            USING(CTL3)
   SORT FROM(OTEMP)                             USING(CTL4)
//INFILE1  DD DSN=G1XXXXXX.DB2.GDGB0921,DISP=SHR           
//INFILE2  DD DSN=G1XXXXXX.DB2.GDGB0922,DISP=SHR           
//CTL1CNTL DD *                                             
   SORT   FIELDS=(1,22,CH,A)                               
   SUM    FIELDS=NONE                                       
   OUTREC FIELDS=(1,22,12C'0',23,4,C'000001')               
//CTL2CNTL DD *                                             
   SORT   FIELDS=(1,22,CH,A)                               
   SUM    FIELDS=NONE                                               
   OUTREC FIELDS=(1,10,12C'0',11,16,C'000002')                       
//CTL3CNTL DD *                                                     
  SORT FIELDS=(1,10,CH,A)                                           
  SUM  FIELDS=(39,6,ZD,11,24,ZD)                                     
  OUTFIL FNAMES=OTEMP1,INCLUDE=(27,6,CH,EQ,C'000001'),               
         OUTREC=(1,22,12C'0',23,4)                                   
  OUTFIL FNAMES=OTEMP2,INCLUDE=(27,6,CH,EQ,C'000002'),               
         OUTREC=(1,10,12C'0',23,16)                                 
  OUTFIL FNAMES=OTEMP3,                                             
         INCLUDE=((27,6,CH,GT,C'000002'),AND,(11,12,CH,NE,23,12,CH)),
         OUTREC=(1,38)                                               
//CTL4CNTL DD *                                                     
  SORT FIELDS=COPY                                                   
  OUTFIL FNAMES=OFILE1,INCLUDE=(35,4,CH,EQ,C'XXXX'),                 
         OUTREC=(1,34,C'ZZZA')                                       
  OUTFIL FNAMES=OFILE2,INCLUDE=(35,4,CH,EQ,C'YYYY'),                 
         OUTREC=(1,34,C'ZZZB')                                       
//INTEMP1  DD DSN=&&INTEMP1,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)   
//INTEMP2  DD DSN=&&INTEMP2,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//INTEMP   DD DSN=*.INTEMP1,VOL=REF=*.INTEMP1,DISP=(OLD,PASS)   
//         DD DSN=*.INTEMP2,VOL=REF=*.INTEMP2,DISP=(OLD,PASS)   
//OTEMP1   DD DSN=&&OTEMP1,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//OTEMP2   DD DSN=&&OTEMP2,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//OTEMP3   DD DSN=&&OTEMP3,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//OTEMP    DD DSN=*.OTEMP2,VOL=REF=*.OTEMP2,DISP=(OLD,PASS)     
//         DD DSN=*.OTEMP3,VOL=REF=*.OTEMP3,DISP=(OLD,PASS)     
//OFILE1   DD DSN=G1XXXXXX.ZZZZ.AACHANGE,
//            DISP=(OLD,CATLG,CATLG),       
//            SPACE=(CYL,(20,20),RLSE)       
//OFILE2   DD DSN=G1XXXXXX.ZZZZ.BBCHANGE,
//            DISP=(OLD,CATLG,CATLG),       
//            SPACE=(CYL,(20,20),RLSE)       
//*


Trying to find out if there is an unknown mistake in the code. Any suggestions would be of great help. I have written another job, (actually 2 jobs, one ICETOOL and another using the SPLICE operator) which is giving me the desired result. But I want to minimize the number of JOBS or STEPS and write an efficient job which will do it in fewer steps. That is what the code copied above is trying to do.
Back to top
View user's profile Send private message
solitude bliss
Beginner


Joined: 16 Jan 2004
Posts: 8
Topics: 3

PostPosted: Tue Oct 03, 2006 2:10 pm    Post subject: Reply with quote

I even tried to use the instream data and test. It works perfectly fine for any other record than the one I have mentioned in the previous email.

Code:
//INFILE1  DD *                 
0040033002000000040033XXXX...   
0040051002000000040051XXXX...   
//INFILE2  DD *                 
0040033002000000040033XXXX...   
0040051002000000040053XXXX... 


Code:
Output
0040051002000000040051000000040053ZZZA


Output is as expected.

Now, when I use the problem record,

Code:
//INFILE1  DD *               
0000273902000000000273XXXX... 
0040051002000000040051XXXX... 
//INFILE2  DD *               
0000273902000000000273XXXX... 
0040051002000000040053XXXX... 


Code:
Output,
0000273902000000000000000000000273ZZZA
0040051002000000040051000000040053ZZZA


Observed that for record, 0000273902000000000273XXXX... , the output file has 0000273902000000000000000000000273ZZZA - Zeroes in col 11-22 (which is from infile1).
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Oct 03, 2006 2:27 pm    Post subject: Reply with quote

Quote:
I have written another job, (actually 2 jobs, one ICETOOL and another using the SPLICE operator) which is giving me the desired result. But I want to minimize the number of JOBS or STEPS and write an efficient job which will do it in fewer steps. That is what the code copied above is trying to do.


Huh? Why would you need one ICETOOL and another using the SPLICE operator? You can do multiple operations in one ICETOOL step (as you're doing in the job you show). And why do you assume that your ICETOOL job with four SORT operators is more efficient than an ICETOOL job with I assume two COPY operators and a SPLICE operator? If anything your job with the four SORT operators seems overly complicated.

If I was going to do this, I'd SPLICE the two records for each key together, do the compare on the single record, and output the needed fields. I could show you how to do that, but I'd rather not reinvent the wheel if you've already done it with the SPLICE job you're talking about. If you do want me to show you how to do it, tell me the RECFM and LRECL of each input file.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
solitude bliss
Beginner


Joined: 16 Jan 2004
Posts: 8
Topics: 3

PostPosted: Tue Oct 03, 2006 2:55 pm    Post subject: Reply with quote

Frank,

Thank you for the response.

Here is the other job that I am using.

Code:
//**********************************************************************
//JSTEP010 EXEC PGM=ICETOOL                                             
//**********************************************************************
//TOOLMSG  DD  SYSOUT=*                                                 
//DFSMSG   DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSOUT   DD  SYSOUT=*                                                 
//TOOLIN   DD *                                                         
   SORT FROM(INFILE1) TO(INTEMP1)               USING(CTL1)             
   SORT FROM(INFILE2) TO(INTEMP2)               USING(CTL2)             
   SORT FROM(INTEMP)                            USING(CTL3)             
//INFILE1  DD DSN=G1XXXXX.DB2.GDGB0921,DISP=SHR                       
//INFILE2  DD DSN=G1XXXXX.DB2.GDGB0922,DISP=SHR                       
//CTL1CNTL DD *                                                         
   SORT   FIELDS=(1,22,CH,A)                                           
   SUM    FIELDS=NONE                                                   
   OUTREC FIELDS=(1,26,C'000001')                                       
//CTL2CNTL DD *                                                         
   SORT   FIELDS=(1,22,CH,A)                                           
   SUM    FIELDS=NONE                                                   
   OUTREC FIELDS=(1,26,C'000002')                               
//CTL3CNTL DD *                                                 
   SORT FIELDS=(1,22,CH,A)                                       
   SUM  FIELDS=(27,6,ZD)                                         
   OUTFIL FNAMES=OFILE1,INCLUDE=(27,6,CH,EQ,C'000001'),         
                 OUTREC=(1,22,C'000000000000',23,4)             
   OUTFIL FNAMES=OFILE2,INCLUDE=(27,6,CH,EQ,C'000002'),         
                 OUTREC=(1,10,C'000000000000',11,12,23,4)       
   OUTFIL FNAMES=OFILE3,INCLUDE=(27,6,CH,GT,C'000002'),         
                 OUTREC=(1,22,23:11,12,23,4)                     
//INTEMP1  DD DSN=&&INTEMP1,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//INTEMP2  DD DSN=&&INTEMP2,DISP=(,PASS),SPACE=(CYL,(20,20),RLSE)
//INTEMP   DD DSN=*.INTEMP1,VOL=REF=*.INTEMP1,DISP=(OLD,PASS)   
//         DD DSN=*.INTEMP2,VOL=REF=*.INTEMP2,DISP=(OLD,PASS)   
//OFILE1   DD  DSN=G1XXXXX.INFILE1.ONLY,                   
//             DISP=(OLD,CATLG,CATLG),                           
//             SPACE=(CYL,(20,20),RLSE)                         
//OFILE2   DD  DSN=G1XXXXX.INFILE2.ONLY,                     
//             DISP=(OLD,CATLG,CATLG),                           
//OFILE3   DD  DSN=G1XXXXX.INBOTH.ONLY,
//             DISP=(OLD,CATLG,CATLG),       
//             SPACE=(CYL,(20,20),RLSE)     
//**********************************************************************
//JSTEP020  EXEC PGM=ICETOOL                                             
//**********************************************************************
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD DSN=G1XXXXX.INFILE2.ONLY,DISP=SHR                     
//IN2      DD DSN=G1XXXXX.DB2.GDGB0921,DISP=SHR                       
//T1       DD DSN=&&T1,UNIT=3390,SPACE=(CYL,(25,25)),DISP=(,PASS)       
//T2       DD DSN=&&T1,UNIT=3390,SPACE=(CYL,(25,25)),DISP=(,PASS)       
//CNCT     DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)                     
//         DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)                     
//OUT      DD DSN=G1XXXX.COMPARE.PACHANGE,DISP=(OLD,CATLG),             
//            SPACE=(CYL,(25,25))                                       
//TOOLIN   DD *                                                         
*                                                                       
  COPY FROM(IN1) TO(T1) USING(CPY1)                                     
  COPY FROM(IN2) TO(T2) USING(CPY2)                                     
  SPLICE FROM(CNCT) WITHALL ON(1,10,CH) WITH(11,12) TO(OUT) 
/*                                                           
//CPY1CNTL DD *                                             
 OUTREC FIELDS=(1,38)                                       
/*                                                           
//CPY2CNTL DD *                                             
 OUTREC FIELDS=(1,22,C'000000000000',23,4)                   
/*                                                           


LRECL and RECFM of the input files: 29 and FB.

Request you to let me know better ways of doing it. Thank you.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Oct 03, 2006 4:56 pm    Post subject: Reply with quote

Well, if I understand what you're trying to do, this DFSORT/ICETOOL job will do it:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/29)
//IN2 DD DSN=...  input file2 (FB/29)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/34)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,10,CH) -
  WITH(23,12) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,10,11:11,12,23:12X)
/*
//CTL2CNTL DD *
  INREC BUILD=(1,10,23:11,12)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(11,12,CH,NE,23,12,CH)
/*


When I run this job, OUT has:

0040051002000000040051000000040053

When I run your job, OUT has:

0040051002000000040051000000040053XXXX

But you said that "the output file should have [Primary key, Field 11 to 22 from file 1, Field 11 to 22 from file 2]", so that would give the 34 bytes I got rather than the 38 bytes you got. Did I misunderstand something?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
solitude bliss
Beginner


Joined: 16 Jan 2004
Posts: 8
Topics: 3

PostPosted: Tue Oct 03, 2006 8:55 pm    Post subject: Reply with quote

No Frank. You got it all correct. I had split the output file into 2 different files based on the last 4 columns. I did not make a perfect problem statement when I first posted the question.

Thanks for the response and a wonderful solution. I am yet to try it out, shall do it first thing in the morning tomorrow morning. Very Happy
Back to top
View user's profile Send private message
solitude bliss
Beginner


Joined: 16 Jan 2004
Posts: 8
Topics: 3

PostPosted: Wed Oct 04, 2006 3:12 pm    Post subject: Reply with quote

Thanks Frank. The code worked perfectly fine.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Oct 04, 2006 4:02 pm    Post subject: Reply with quote

Glad I could help.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group