|
|
| Author |
Message |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
Hi,
I have a requirement in which I have 2 files, let's say FileA and FileB.
Consider it like this.
FileA
key01 100
key02 200
key03 300
FileB
key01 100
key02 250
key04 400
Both the Input files will be in the sorted order of their Key(First 5 bytes).
Input files are of LRECL 80.
I want
1) The records in FileA and FileB which has same key and different amounts in one file.
2) The records which are there in only fileA(Based on key) in second output file.
3) The records which are there only in FileB(Based on key) in third output file.
All those records which has same key and amount in both the files should not come in any of these output files.
So in the above shown example, my output should be
OUTPUT1
Key02 200 (amount value taken from 1st file)
OUTPUT2
key03 300
OUTPUT3
key04 400
And since the record 'key01 100' is coming in both files, it should be skipped.
I searched for some similar requirement in the earlier posts, but coulnot lay my hands on any..  |
|
| Back to top |
|
 |
References
|
|
 |
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 185 Location: Chennai
|
|
|
|
Is it a must that the three files should be produced only by sort?If it is easytrieve or COBOL i believe things will be simple .  |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
hey
I want it using Sort only. Using Cobol i can code a program, but my concern is if the input file contains millions of records, then it might cause perfomance degradation for Cobol.
I think Sort will be faster in that case.. ( I THINK )
anyway i need a sort step to do this part if possible..
any help ??????? |
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3511 Location: Brussels once more ...
|
|
|
|
Which sort product are you using ?
I have done some things remotely similar using DFSORT. |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
| Can u explain on that Expat... am using DFSORT ... |
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3511 Location: Brussels once more ...
|
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3511 Location: Brussels once more ...
|
|
|
|
| Code: |
//ICETOOL6 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INFILE DD DSN=&&SORTOUT,DISP=SHR
// DD DSN=&&MFXSSORT,DISP=SHR
// DD DSN=&&B41SSORT,DISP=SHR
//OUTFILE DD DSN=&&MERGE2X,DISP=(,PASS),
// SPACE=(CYL,(100,25),RLSE)
//MERGED DD DSN=&&MERGED,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(100,25),RLSE)
//TOOLIN DD *
*** SELECT ONLY RECORDS WITH NON MATCHING KEYS
*** THEN COPY TO INCLUDE ONLY D AND M RECORD TYPES
SELECT FROM(INFILE) TO(OUTFILE) -
ON(5,44,CH) ON(51,8,CH) NODUPS
COPY FROM(OUTFILE) TO(MERGED) USING(COPY)
/*
//COPYCNTL DD *
OPTION VLSCMP
INCLUDE COND=(64,1,CH,EQ,C'D',OR,64,1,CH,EQ,C'M')
/*
|
The SELECT compares the two fields that I have specified and if they are not matched then the NODUPS statement will keep them.
The COPY after the SELECT is only used to further cut down on records that I do not require.
If you look at the JCL I am actually reading three files but only producing one, but ICETOOL is such a versatile tool which will allow you to do what you want. |
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3511 Location: Brussels once more ...
|
|
|
|
Sorry, I forgot to add that you can create all three output files in one job step.
I have the luxury of having specific record types to work with to make record selection easier, but if you have nothing like that in your files you may have to reformat them with "A" in a specific column for FILEA, "B" for records from FILEB, etc. etc.
I'm not the greatest user of ICETOOL and it is really great for things like this, and I'm sure that Frank will far more helpful with this utility than I ever can.
Good luck. |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
Hi
Expat, thanks for ur immediate responses.....
let me ask u a doubt.
Using the code given above, the first SELECT will eliminate ALL the duplicate records from the input files.
using the COPY i can then split this file into two based on their presence in 1st file or 2nd file.
My question is, how can i identify a key which is present in both the files but with different amounts.. ( like the KEY02 in my example)
I want to write such records in to another file.. |
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3511 Location: Brussels once more ...
|
|
|
|
Yes, I think that the code will remove all of the duplicates which will give you your OUTPUT 1.
If there is no way of telling from which file the records have come from, you may have to reformat the records before processing them.
Some thing silly like F1 in columns 1+2 for file 1 records and F2 for file 2 records. And after you have processed them to reformat by removing the F1 & F2 inserts.
I sort of get the feeling I'm confusing you more than helping here  |
|
| Back to top |
|
 |
Alain Benveniste
Active User
Joined: 14 Feb 2005 Posts: 90
|
|
|
|
raak,
Do you have duplicates in file 1 & 2 ?
Alain |
|
| Back to top |
|
 |
GlobalGyan
New User
Joined: 31 Jan 2006 Posts: 17
|
|
|
|
I did something like this some time back...
I dont have the ICETOOL CNTL ... but then I coded a COBOL program for this, the code executed 50% faster than SORT ... maybe that time I did not ask Frank ;-). |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
Hi Alain,
I don't have any duplicates in my file 1 or 2..
Any updates??? |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
Raak,
Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your amount field was 3 digits in positions 7-9. - if that's not the case, then the job can be changed appropriately.
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT1 DD DSN=... output file1 (FB/80)
//OUT2 DD DSN=... output file2 (FB/80)
//OUT3 DD DSN=... output file3 (FB/80)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(1,5,CH) KEEPNODUPS -
WITH(81,80) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(1,80,160:X)
/*
//CTL2CNTL DD *
INREC BUILD=(1,5,81:1,80)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT1,
INCLUDE=(7,3,CH,NE,C' ',AND,87,3,CH,NE,C' ',
AND,7,3,CH,NE,87,3,CH),
BUILD=(1,80)
OUTFIL FNAMES=OUT2,
INCLUDE=(87,3,CH,EQ,C' '),
BUILD=(1,80)
OUTFIL FNAMES=OUT3,
INCLUDE=(7,3,CH,EQ,C' '),
BUILD=(81,80)
/*
|
|
|
| Back to top |
|
 |
Rahulbhutkar
New User
Joined: 30 Mar 2007 Posts: 1 Location: mumbai
|
|
|
|
Hi Frank,
I am very new to mainframe & learning sort. If u could explain me splice and control card 1 & 2 it would be gr8 on my side.
Thanks,
Rahul |
|
| Back to top |
|
 |
|
|
|