View previous topic :: View next topic
|
Author |
Message |
a69356
New User
Joined: 01 Dec 2006 Posts: 21 Location: Gurgaon
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
1. SYNCSORT
2. LREC = 30, RECFM=30000
3. Position=1, Length=8, The Key fields are character (CH). |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
kedianirmal
New User
Joined: 08 Feb 2008 Posts: 82 Location: Bangalore, India
|
|
|
|
Alissa,
It will be great if you will explain the SORT card. |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
V S Amarendra Reddy
Active User
Joined: 13 Sep 2006 Posts: 216 Location: USA
|
|
|
|
Hi Alissa,
can you please post the link to download the PDF of syncsort if possible.
Regards
Amar |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
|