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
 
Help Needed with Sum fields in SOrt

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Help Needed with Sum fields in SOrt
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: 1703
Location: Australia

PostPosted: Thu Aug 06, 2009 5:21 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Aug 06, 2009 8:49 pm    Post subject:
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    Post subject:
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    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 Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am
No new posts SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am

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