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

Comparing two files through Sort.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
a69356

New User


Joined: 01 Dec 2006
Posts: 21
Location: Gurgaon

PostPosted: Fri May 07, 2010 12:01 pm
Reply with quote

I have two files let say A and B.

I want to compare both and write all the matches to another file say C and all mismatches to another file say D.

Is it possible to do with Sort or is there any other way to achieve the above requirement through JCl?

Any help will be highly appreciated.

Thanks,
Ashish
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri May 07, 2010 12:12 pm
Reply with quote

What sort product you are working on?

what is LRECL\RECFM of the file.

If you are using DFSORT\ICETOOL then check in DFSORT tricks by Frank
I think what you are looking for is there in it.
Link: www-01.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
Topic:Create files with matching and non-matching records

If you need something different than this post sample records
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Fri May 07, 2010 9:07 pm
Reply with quote

SyncSort's JOIN feature can easily do this for you. If you provide the RECFM and LRECL of the files, we will be able to provide you with a more detailed response.
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Mon May 10, 2010 7:58 pm
Reply with quote

I have a similar query with a little more requirement
File A:
000501300603
000501300610
000501304711
000501304869
000501307030
000501307770
000501307777
000501308880
000501308882
000501308887
000501308888
000501308889

File B:
000501300603
000501304711
000501304869
000501307030
000501307770
000501308882
000501308887
000501308889
095900664869

File A & B have few records matching and the files are sorted too. But the frist record in file A may be the 3rd record in the file B or vice versa.

My Requirement is all the records which are matching in both the files irrespective of their sequence number in the file should be written to one file 'C'. The records of file 'A' which are not matched with 'B' should go to File 'D' and the records of file 'B' not matched with 'A' to be written to file 'E'.
Can this be possible in SORT or any solution close to this requirement.
Consider the key as 1-8 to match the records.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon May 10, 2010 8:06 pm
Reply with quote

kedianirmal
Which sort product do you use at your site.
RECFM & LRECL of both files.
Position, length and format of the key fields in both files.
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Mon May 10, 2010 8:39 pm
Reply with quote

1. SYNCSORT
2. LREC = 30, RECFM=30000
3. Position=1, Length=8, The Key fields are character (CH).
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Mon May 10, 2010 9:56 pm
Reply with quote

Here is a SyncSort for z/OS job that will do what you asked:
Code:

//SORT1 EXEC PGM=SORT   
//SORTJNF1 DD *         
000501300603           
000501300610           
000501304711           
000501304869           
000501307030           
000501307770           
000501307777           
000501308880           
000501308882           
000501308887           
000501308888           
000501308889           
//SORTJNF2 DD *                 
000501300603                     
000501304711                     
000501304869                     
000501307030                     
000501307770                     
000501308882                     
000501308887                     
000501308889                     
095900664869                     
//SORTOF01 DD SYSOUT=*   (FILE-C)
//SORTOF02 DD SYSOUT=*   (FILE-D)
//SORTOF03 DD SYSOUT=*   (FILE-E)
//SYSOUT DD SYSOUT=*             
//SYSIN DD *                                             
   JOINKEYS FILES=F1,FIELDS=(1,8,A),SORTED               
   JOINKEYS FILES=F2,FIELDS=(1,8,A),SORTED               
   JOIN UNPAIRED                                         
   REFORMAT FIELDS=(F1:1,30,F2:1,30)                     
   SORT FIELDS=COPY                                       
   OUTFIL FILES=03,INCLUDE=(1,8,CH,EQ,C' '),BUILD=(31,30)
   OUTFIL FILES=02,INCLUDE=(31,8,CH,EQ,C' '),BUILD=(1,30)
   OUTFIL FILES=01,SAVE                                   
/*                                                       
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Mon May 10, 2010 10:38 pm
Reply with quote

Alissa,

It will be great if you will explain the SORT card.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Mon May 10, 2010 11:17 pm
Reply with quote

JOIN UNPAIRED indicates that you want both the paired and unpaired records created from the JOIN processing.

The REFORMAT statement specifies how the records are going to be formatted after JOIN processing. In this case, you are writing out 30 bytes from SORTJNF1 followed by 30 bytes from SORTJNF2. If a field is not present, by default it will be filled with blanks (X'40').

Since you are not re-sequencing the records after JOIN processing, only a COPY is necesary.

Then there are 3 OUTFIL statements.
- The records to be included in SORTOF03 have blanks in position (1,8), which would indicate that this is a non-paired record from SORTJNF2.
The BUILD statement here simply removes the blank filler portion of the record.
- The records to be included in SORTOF02 have blanks in position (31,8), which would indicate that this is a non-paired record from SORTJNF1.
The BUILD statement here simply removes the blank filler portion of the record.
- The records to be included in SORTOF01 are the remaining records which are not written to any of the other OUTFILs. Hence in this scenario, they would be the paired (matching) records.
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Tue May 11, 2010 2:41 pm
Reply with quote

Hi Alissa,

can you please post the link to download the PDF of syncsort if possible.

Regards
Amar
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue May 11, 2010 2:57 pm
Reply with quote

V S Amarendra Reddy wrote:
Hi Alissa,

can you please post the link to download the PDF of syncsort if possible.

Regards
Amar

ibmmainframes.com/viewtopic.php?t=41086&highlight=alissa+manuals
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue May 11, 2010 3:13 pm
Reply with quote

SyncSort Documentation is covered under Copyright Act, suggest you get in touch with Alissa with the CPU details to which the product is licensed to, she will then tell you if you can get the documentation or not.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top