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

Help Needed with Sum fields in SOrt


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

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Thu Aug 06, 2009 1:02 pm
Reply with quote

hi

Can Any one help me in addressing the issue related to summing of the fields using sum fields option in sort.

I have a file with three columns as shown below


Code:

62152115              +72.000              16109
62152115              -24.000              16109
62152115               24.000              16448
62152115               24.000              19177
62152115               48.000              19208
62152115               24.000              19213
62152115               24.000              19244
62152115             +120.000              16109


and i need to add the column 2 records when the column1 and column3 combinations are repeated

For instance : for this input

62152115 72.000 16109
62152115 -24.000 16109

in the output i need only one record that should have

Code:
62152115               48.000              16109
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Aug 06, 2009 5:21 pm
Reply with quote

Hi,

what about this line ?
Code:
62152115             +120.000              16109


Gerry
Back to top
View user's profile Send private message
pnr kishore

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Thu Aug 06, 2009 5:44 pm
Reply with quote

hi,

Even this Record has to be accounted . For Better understanding i have take only two records to illustrate my requirement.

Quote:

For instance : for this input

62152115 72.000 16109
62152115 -24.000 16109

in the output i need only one record that should have
62152115 48.000 16109
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: Thu Aug 06, 2009 8:49 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
62152115              +72.000              16109
62152115              -24.000              16109
62152115               24.000              16448
62152115               24.000              19177
62152115               48.000              19208
62152115               24.000              19213
62152115               24.000              19244
62152115             +120.000              16109
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC OVERLAY=(21:21,9,SFF,TO=ZD,LENGTH=9)
  SORT FIELDS=(1,8,CH,A,44,5,CH,A)
  SUM FIELDS=(21,9,ZD)
  OUTREC OVERLAY=(21:21,9,ZD,EDIT=(SIIIT.TTT),SIGNS=(+,-))
/*


SORTOUT would have:

Code:

62152115             +168.000              16109     
62152115              +24.000              16448     
62152115              +24.000              19177     
62152115              +48.000              19208     
62152115              +24.000              19213     
62152115              +24.000              19244     
Back to top
View user's profile Send private message
pnr kishore

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Fri Aug 07, 2009 3:35 pm
Reply with quote

Thanks Alot icon_biggrin.gif
it worked for me...
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top