Page 1 of 2

Duplicate removal and sum

PostPosted: Wed Dec 16, 2009 11:40 pm
by storage
Hello ,
I have an urgent requirement..I have the following data..

aaaa 11 2
bbb 44 3
aaa 22 4

I need to remove the duplicates and add the sum....
The output shld be as below
aaa 33 6
bbb 44 3
Can someone plse help...

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 1:12 am
by dick scherrer
Hello,

If this is truly urgent, you have hopefully started writing some code.

It is completely inappropriate to post "urgent requirements" on this forum. . .

d

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 1:15 am
by Frank Yaeger
Since this is "urgent", you should have spent some more time giving the details of your requirement.

What is the RECFM and LRECL of your input file? What is the starting position, length and format of each field?

Assuming that the first field is in positions 1-3, the second field is in positions 9-10 and the third field is in position 14 (which I doubt is the case), you could use these DFSORT control statements:

   OPTION ZDPRINT
   SORT FIELDS=(1,3,CH,A)
   SUM FIELDS=(9,2,ZD,14,1,ZD)


If my assumptions are wrong, you need to give the correct information.

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 4:14 pm
by storage
Thanks Frank for a quick response...

I have few questions:
-->what is it which is removing the duplicate data?
Coz when I m running the job not all duplicate data is being removed.
-->Also many times I m getting S0c4 abend and when I do couple of reruns it works fine...there seems to be something which I m missing..
Please help..

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 4:17 pm
by storage
The below is the abend..
ICE185A 0 AN S0C7 ABEND WAS ISSUED BY DFSORT, ANOTHER PROGRAM OR AN EXIT (PHASE S 1)

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 4:52 pm
by storage
I understood that the sum parameter is removing dups..But it's not removing all dups for my dataset.

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 9:20 pm
by expat
Frank Yaeger wrote:Since this is "urgent", you should have spent some more time giving the details of your requirement.

Perhaps if you gave Frank the relevant information, a solution could be found faster.

Re: Duplicate removal and sum

PostPosted: Thu Dec 17, 2009 11:09 pm
by Frank Yaeger
Sigh.

The SUM statement keeps one record from each set of duplicates and adds the indicated fields from that set of duplicates.

An S0C7 is probably caused by using SUM for "bad" data. As I said, I assumed you had CH and ZD data in certain positions, but you probably don't. You need to tell me the layout of the records, that is, starting position, length and format of each field.

Re: Duplicate removal and sum

PostPosted: Mon Dec 21, 2009 9:30 pm
by storage
Hello,
The below is the sample data :
It is to be sorted from 1-8 and the sum shld be frm 11-19 and 22-29

BATDEV    1888007    2771500
BATDEV    1429161    2771500


When I trying to use the program it's giving me S0C7..

Re: Duplicate removal and sum

PostPosted: Mon Dec 21, 2009 11:19 pm
by Frank Yaeger
I don't know how you expect anyone to help you when you don't answer the questions asked and can't describe your requirement correctly.

Again: What is the RECFM and LRECL of your input file?

You say that the sum fields should be from 11-19 and 22-29, but in your example it looks like they are really at 11-17 and 22-28. Please give accurate positions for your fields that correspond to your example. If you don't use the correct positions in your control statements, then it's no surprise you'd get an S0C7.