Posted: Mon Aug 11, 2003 6:34 am Post subject: SORT
I have two files with key as Account Number. I have only A/c numbers in one file and all the infomation related to that A/c number in another file. By comparing the two files i want to extract the whole A/c information by using the SORT command thru JCL.
Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
Posted: Mon Aug 11, 2003 9:23 am Post subject:
Kishore,
couple of questions before I post the solution .
1. what is the LRECL,RECFM of the 2 files.
2. what is the position,format of the account number.
3. Do any of the files contain duplicates? (especially the account info file)
4. Last but not least what sort product does your shop have ( DFSORT , syncsort)
5. Is easytrieve an option??
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Aug 11, 2003 11:06 am Post subject:
Kishore,
You can do what you want with the following DFSORT job:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN2 DD DSN=... input file2
//TEMP2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CONCT DD DSN=... input file1
// DD DSN=*.TEMP2,VOL=REF=*.TEMP2,DISP=(OLD,PASS)
//OUT DD DSN=... output file
//TOOLIN DD *
* Put key from file2 in same positions as in file1
COPY FROM(IN2) TO(TEMP2) USING(CTL2)
* Get each file record with a matching key in file2
SELECT FROM(CONCT) TO(OUT) ON(6,6,CH) FIRSTDUP
/*
//CTL2CNTL DD *
OUTREC FIELDS=(6:3,6,100:X)
/*
For your example, the output will be:
Code:
RAMIO345678DEF
ASHOK545489ERT
If you need the output records sorted by positions 1-5, you can add another SORT operator to do that. Let me know if you need me to show you how. _________________ 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
Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
Posted: Mon Aug 11, 2003 11:11 am Post subject:
Kishore,
The following DFSORT/ICETOOL Jcl will give you the desired results.A brief explanation of the job.
we first take your file2 which just has the account # and reformat to the length of file1 while placing the key(account # ) in position 6 and write it out to temp file T1.
Now we concatenate your file1 with the T1 and select only duplicates.Any matching record from file2 will be a duplicate and we are only taking the FIRSTDUP which will come from file1 as file1 is first in the concatenation.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Aug 11, 2003 12:31 pm Post subject:
Kolusu,
Wow, it isn't often that I beat you in posting (by all of 5 minutes this time). Usually, by the time I see the question here on the West Coast (US), you've already answered it. Being newly married must be slowing you down (it doesn't affect old married people like me).
OPTION EQUALS isn't needed - SELECT sets it automatically. _________________ 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
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