Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comparing two files through Sort.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Comparing two files through Sort.
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    Post subject:
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: http://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: 500
Location: USA

PostPosted: Fri May 07, 2010 9:07 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Mon May 10, 2010 8:06 pm    Post subject:
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    Post subject:
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: 500
Location: USA

PostPosted: Mon May 10, 2010 9:56 pm    Post subject:
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    Post subject:
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: 500
Location: USA

PostPosted: Mon May 10, 2010 11:17 pm    Post subject:
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: 189
Location: INDIA

PostPosted: Tue May 11, 2010 2:41 pm    Post subject:
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    Post subject:
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

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

Senior Member


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

PostPosted: Tue May 11, 2010 3:13 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us