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..
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..
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
Hi Raak,
here's the url for the ICETOOL utility, and I will try and find an example of the code that will help you. No doubt Frank will give you something far more efficient than mine, but if it help .........
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
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
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.
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
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.
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..
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
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
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 ;-).
Joined: 15 Feb 2005 Posts: 7129 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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Rahul,
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: