Logic:
For unique value of Field-1, if the value of field-2 = 2, count the unique values of field-3 and field-4 (ignoring 0).
Required Output:
Code:
111 2 1
222 3 2
My last call was to create a Cobol code with a logic that, with every read, fill an array for field-3 and field-4 with unique record and when field-1 changes, get the array size. But since my input file has millions of records, doing a search for each record doesn't seems to be a good idea. I just hope if there is something in JCL which could be more suitable.
Let me know if I had missed any important information. Your suggestion could be very helpful. Thanks.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
The reason for that is that it will require the file to be sorted, twice, when for your COBOL program the order is already adequate.
You can use this to check the output from the COBOL program during testing. This will only work if your SORT package supports JNFnCTNL files. Give it a whirl with the data you showed.
Thank you so much for your valuable time. As suggested by you I would opt to use Cobol.
I would be using 2 arrays for storing unique values of field-3 and field-4 for every particular value of field-1. At every change in field-1, write the array count in output file and initialize the array. For this the code would need to search array for every record to check if it there in array or not and update array if it is new entry. Probably doing a search for millions of input record into array which could have length of around a million would take time. So was just looking for any better options. With your suggestion I am no more confused now. Thanks
The test JCL provided by you would be of great help. Thanks again.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Unless you are badly misrepresenting your data, the task is routine.
With records of type you want and not zero, stick the two values into two separate (COBOL internal) tables.
To do the sticking, you see if the value already exists. If it doesn't you add an entry for it.
On change of key, number of entries in your two tables gives you the answer you want.
I can see nothing complicated or in any way time-consuming (beyond what is needed) in that outline. No sorting needed, no fancy techniques, just plain stuff.