IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

sum of the records having the same key


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ejpreddy

New User


Joined: 24 Jul 2006
Posts: 2

PostPosted: Mon Jul 24, 2006 7:55 pm
Reply with quote

Hi,

I have the following i/p file

Code:

1111           mahi          234
2345           jaggu         123
1111           jagan         256
3467           anil          256
2345           madan         123


The output should be

Code:

1111           mahi          234      2
1111           jagan         256      2
2345           jaggu         123      2
2345           madan         123      2
3467           anil          256      1



That means o/p should be sorted on 1st field and for every duplicate for that key, a filed should be added which contains the number of records that has the same key in the entire file.

Please let me know a simple way to acheive this.

Thanks,
ejpreddy
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jul 24, 2006 9:13 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/32)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT DD DSN=...  output file (FB/39)
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,4,CH) -
  WITHALL WITH(1,32)
/*
//CTL1CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(1,4,CH,A)
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
    OUTREC=(39X),
    SECTIONS=(1,4,
      TRAILER3=(1,32,39:COUNT=(EDIT=(T))))
  OUTFIL FNAMES=T2,OUTREC=(1,32,39:X)
/*
Back to top
View user's profile Send private message
ejpreddy

New User


Joined: 24 Jul 2006
Posts: 2

PostPosted: Fri Jul 28, 2006 5:54 pm
Reply with quote

Hi,
Thanks for your reply.It is working fine for the input given above.However When the input is having more than 10 duplicate records,I am getting only the last digit of the count.For exaple if there are 13 records with the duplicate key,I am getting only 3.Is there any solution to get 13.

Is there anyway,so that output should have the records in the order as input that means without sorting and the last column is the sum of duplicates.please let me know.

Thanks,
EJPREDDY
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Fri Jul 28, 2006 11:52 pm
Reply with quote

Hi,
It seems you need to change the COUNT=(EDIT=(T)))) to COUNT=(EDIT=(TT)))).

The o/p length of the count field has defined with length 1 so the value is truncating.

Thank you
Krishy
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Aug 05, 2006 10:02 pm
Reply with quote

EJPREDDY,

I gave you what you asked for. You showed a 1-digit count in your output so that's what I gave you by using EDIT=(T). As Krishy pointed out you can use EDIT=(TT) to get a 2-digit count (or EDIT=(TTT) to get a 3-digit count, etc). In the future, please be more careful to ask for what you actually want.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top