Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us