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 

Want to compare two files using DFSORT or ICETOOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
chethanm
Beginner


Joined: 11 Jul 2009
Posts: 3
Topics: 1
Location: Bangalore

PostPosted: Mon Jul 13, 2009 12:13 am    Post subject: Want to compare two files using DFSORT or ICETOOL Reply with quote

Hi,

I want to compare two files A & B and I have to write the matched record output in another file.The sequence of the records should not change and It should be in the sequence as shown below.

File A
...1231...a...
...2231...a...
...1111...a...


File B ( length 260 FB)
...1231...a...
...1232...x...
...1232...x...
...1111...a...
...1112...x...
...1112...x...
...2231...a...
...2232...x...
...2232...x...

Key starts from Position 13 length 3 bytes(i.e.,123,111,223...)

The output rec format should be like shown below
...1231...a...
...1232...x...
...1232...x...
...2231...a...
...2232...x...
...2232...x...
...1111...a...
...1112...x...
...1112...x...

the record sequence should be as showm above.....

Please help me out in this.


Thanks,
chethan M
_________________
Thanks,
Chethan Mallaiah
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12385
Topics: 75
Location: San Jose

PostPosted: Mon Jul 13, 2009 9:57 am    Post subject: Reply with quote

chethanm,

What is the LRECL and RECFM for FILEA ? You mentioned FILEB as 260? Is it FB format or VB format? Also do you duplicates in your fileA?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chethanm
Beginner


Joined: 11 Jul 2009
Posts: 3
Topics: 1
Location: Bangalore

PostPosted: Mon Jul 13, 2009 9:49 pm    Post subject: Reply with quote

FILE A is also of length 260 FB and File A does not contain Duplicates....If the record is present in file B and not in File A then those records should also be written in the output file.
_________________
Thanks,
Chethan Mallaiah
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12385
Topics: 75
Location: San Jose

PostPosted: Mon Jul 13, 2009 10:31 pm    Post subject: Reply with quote

Chethanm,

The following DFSORT JCL will give you the desired results. we create a 1 byte header record in step0100 with the same DCB properties as your input files and concatenate it with your input files which would be used to identify the record to the file when using the group function.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
HDR                                                               
//SORTOUT  DD DSN=&&H,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC OVERLAY=(260:X)                                           
/*                                                                 
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DSN=Your input unique filea,DISP=SHR
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DSN==Your input duplicate fileb,DISP=SHR   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(261:ID=1))     
 SORT FIELDS=(13,3,CH,A),EQUALS
 OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(263:SEQNUM,8,ZD,RESTART=(13,3))),
 IFTHEN=(WHEN=GROUP,BEGIN=(263,8,ZD,EQ,1),PUSH=(262:261,1))           
 OUTFIL INCLUDE=(261,2,ZD,GE,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,260)
/*


For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/

Hope this helps...
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chethanm
Beginner


Joined: 11 Jul 2009
Posts: 3
Topics: 1
Location: Bangalore

PostPosted: Tue Jul 14, 2009 12:51 am    Post subject: Reply with quote

Thanks for your reply.....
I didn't get the desired output....I wanted the output records in the same sequence as that of the FILE A ...but i am getting the output in the sorted order which i don't want...

Obtained output by executing the given JCL

...1111...a...
...1112...x...
...1112...x...
...1231...a...
...1232...x...
...1232...x...
...2231...a...
...2232...x...
...2232...x...

But I wanted the Output as

...1231...a...
...1232...x...
...1232...x...
...2231...a...
...2232...x...
...2232...x...
...1111...a...
...1112...x...
...1112...x...

the output file should be in the same sequence as that of the input FILE A.
Please help me out in this regards....
_________________
Thanks,
Chethan Mallaiah
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12385
Topics: 75
Location: San Jose

PostPosted: Tue Jul 14, 2009 6:48 am    Post subject: Reply with quote

chethanm,

If you want to retain the original order of records then you need another pass of data. Change the step0200 to the following

Code:

//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DSN=Your input unique filea,DISP=SHR
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT         
//         DD DSN==Your input duplicate fileb,DISP=SHR   
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)             
//SYSIN    DD *
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),
 PUSH=(261:SEQ=8,ID=1))     
 SORT FIELDS=(13,3,CH,A),EQUALS
 OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(271:SEQNUM,8,ZD,RESTART=(13,3))),
 IFTHEN=(WHEN=GROUP,BEGIN=(271,8,ZD,EQ,1),PUSH=(270:269,1))           
 OUTFIL INCLUDE=(269,2,ZD,GE,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,268)
/*
//STEP0300 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&T1,DISP=SHR
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                                   
  SORT FIELDS=(261,8,CH,A)
  OUTREC BUILD=(1,260)
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
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 -> Job Control Language(JCL) 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