View previous topic :: View next topic |
Author |
Message |
Vish Beginner
Joined: 17 Sep 2003 Posts: 21 Topics: 9 Location: Mumbai India
|
Posted: Wed Oct 01, 2003 7:13 am Post subject: Select the records of a file matching the key in other file |
|
|
Friends,
I have one transaction file contains 20 fields in each record.The first field in the file is the account number. I have another file containing only active account numbers.
My requirement is to select the transaction records of which the account number matches with the second file. Is this possible by SORT utility ?
Or any other method of doing this apart from writing the program.
Thanks, _________________ Vish |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Oct 01, 2003 10:32 am Post subject: |
|
|
Vish,
If you want more specific help on doing this with DFSORT/ICETOOL, show an example of your input records for the two files, and what you want the output records to look like. Also tell me the RECFM and LRECL of the input files, the starting position and length of the account number in each file, and whether you can have duplicate records within each 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 |
|
|
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Tue Oct 07, 2003 2:24 am Post subject: |
|
|
I think coding EZTreive 'MATCH' will be the simplest solution. |
|
Back to top |
|
|
Vish Beginner
Joined: 17 Sep 2003 Posts: 21 Topics: 9 Location: Mumbai India
|
Posted: Tue Nov 11, 2003 12:17 pm Post subject: |
|
|
Hi Frank,
File A looks like below. Assume first 3 characters constitute key.
200 PETER BANGALORE
300 LILLY MUMBAI
500 TONY DELHI
File B which contains the keys only.
100
300
400
500
600
700
The output file is
300 LILLY MUMBAI
500 TONY DELHI
The records of File A should be written in the output if the key matches with the key in File B.
Thanks
Vish _________________ Vish |
|
Back to top |
|
|
Vish Beginner
Joined: 17 Sep 2003 Posts: 21 Topics: 9 Location: Mumbai India
|
Posted: Tue Nov 11, 2003 12:29 pm Post subject: |
|
|
Hi Frank,
Sorry for missing the LRECL and RECFM in the previous post.
Record length is 80 and Record format is Fixed length.
Thanks, _________________ Vish |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Tue Nov 11, 2003 2:23 pm Post subject: |
|
|
Vish,
This DFSORT/ICETOOL job will do what you asked for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input fileA
// DD DSN=... input fileB
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,3,CH) FIRSTDUP
/*
|
_________________ 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 |
|
|
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Mon Jan 05, 2004 6:26 am Post subject: |
|
|
Frank,
Can you please explain the function of "ON(1,3,CH) FIRSTDUP".
Thanks,
Ravikumar. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Jan 05, 2004 9:49 am Post subject: |
|
|
Ravikumar,
Straight from the manual the parm FIRSTDUP on SELECT statement Limits the records selected to the first record of those with [b]ON[b] i.e (1,3) values that occur more than once (value count > 1). You can use this operand to keep just the first record of those records with duplicate field values.
The manual can be accessed here
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICECA109/CCONTENTS
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Mon Jan 05, 2004 10:21 am Post subject: |
|
|
Ravikumar,
ON(1,3,CH) tells DFSORT/ICETOOL you want to select records based on the character values in positions 1-3. FIRSTDUP tells DFSORT/ICETOOL that you only want to select the first record for each set of duplicates. So if you had the following input records:
Code: |
ZQX R1
RST R1
ABC R1
ABC R2
DEF R1
RST R2
GHI R1
ABC R3
GHI R2
|
your output with ON(1,3,CH) FIRSTDUP would be:
Code: |
ABC R1
GHI R1
RST R1
|
For more information on all of the parameters you can use with the SELECT operator of DFSORT's ICETOOL, see:
http://www.storage.ibm.com/software/sort/mvs/icetool/online/srtmtsel.html _________________ 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 |
|
|
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Tue Jan 06, 2004 10:28 am Post subject: |
|
|
Kolusu/Frank,
Thanks for your explanation.
Frank,
As your o/p shows, the o/p file is sorted based on the key filed.
Will ICETOOL preserve the order from i/p file if two records has the same key while
giving FIRSTDUP.
I/P :
ABC R2
ABC R1
GHI R2
GHI R1
O/P :
ABC R2
GHI R2
Thanks,
Ravikumar. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jan 06, 2004 10:45 am Post subject: |
|
|
Ravikumar,
yes it does preserve the order as SELECT operator of DFSORT's ICETOOL has OPTION EQUALS as default.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Tue Jan 06, 2004 11:17 am Post subject: |
|
|
Ravikumar,
Kolusu is correct. The SELECT operator of DFSORT's ICETOOL passes the EQUALS option to DFSORT telling it to preserve the original order of duplicate records. _________________ 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 |
|
|
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Wed Jan 07, 2004 11:49 am Post subject: |
|
|
Kolusu/Franks
Thanks for your explanation. |
|
Back to top |
|
|
vkphani Intermediate
Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Wed Mar 31, 2004 8:52 am Post subject: |
|
|
Hello Frank Yaeger
In our shop we are using ICETOOL and FIRSTDUP is not working. |
|
Back to top |
|
|
|
|