Posted: Fri Apr 23, 2004 11:53 am Post subject: Group total depending on a field.
Hi,
I have to get the total number of a group depending on a field. But the tricky part is I need to have all the records which are present in the input file and the group total as part of the first record of the respective group.
For example
Input File
Here the field I'm looking to group is at the position 11 and of length 10. The group total is at 112th position and is of length 3. For example If you see the field 53722 it has been repeated three times hence I have to put 03 at the 112th position of the first occurance.
Can I use SYNCSORT to solve this ? _________________ Regds,
Somu
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Apr 23, 2004 12:19 pm Post subject:
Somuk,
A couple of clarifications.
1.What is your LRECL and recfm of the file?
2. In your example , you spaced out the count field for the duplicates(ex: 7324 & 7326 for 53722 key). do you really need to space it out? can it contain a value of '001'?
3. You described the count field to be 3 bytes but you show only 2 bytes for the count. Do you want the count to be '003'?
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Apr 23, 2004 2:02 pm Post subject:
Somuk,
I wrote this on the fly as I was about to leave from work and was not able to test it.so excuse me for any syntax errors.
The following JCL will give you the desired results. A brief explanation of the job. I assumed that you wanted to retain the order of the records as is from the input.
A brief explanation of the job. we add a constant of 001 and seqnum to every record at position 115 using inrec at the end. Since you wanted a space for count field for duplicate we force a space in byte 112 thru 11 for all records.
Now we sort on the key field and sum on the constant we added. All duplicated records will routed to ctl1xsum file and summed up records to temp file T1.Using outrec on the temp file t1, we move the summed up total to bytes 112 thru 114.
The next step we concatenate the temp file t1 and ctl1xsum file and sort on the seqnum to retain the orginal sequence of records. Using outrec we strip the constant and seqnum which leaves you with the desired output.
Great Kolusu. Thank you for the solution.
The only change I did was replacing the insteam data with my input file. Since for instream data it will assume a default LRECL of 80 the INREC statement will give us an out of range condition. Am I right? _________________ Regds,
Somu
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Apr 27, 2004 3:04 pm Post subject:
Somu,
Sorry for the late response. You are right that with instream data, sort will assume the lrecl to be 80 bytes which will result in a WER230A INREC FIELD OUTSIDE RANGE error.
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