Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
sum of the records having the same key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: sum of the records having the same key
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 Moderator


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

PostPosted: Mon Jul 24, 2006 9:13 pm    Post subject:
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    Post subject: Re: sum of the records having the same key
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    Post subject:
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 Moderator


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

PostPosted: Sat Aug 05, 2006 10:02 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm
No new posts how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm
No new posts Merging records, but not all the time prino DFSORT/ICETOOL 17 Sat Feb 17, 2018 4:20 pm
No new posts Need all records with high key kalidasvs SYNCSORT 15 Fri Feb 09, 2018 10:38 pm
No new posts Why is SORT rearranging records that ... cschablow DFSORT/ICETOOL 4 Wed Jan 24, 2018 10:14 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us