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
 

 

Need to have a sort jcl with summing up accounts

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
shakti

New User


Joined: 20 Jan 2004
Posts: 42

PostPosted: Wed Feb 15, 2006 6:37 pm    Post subject: Need to have a sort jcl with summing up accounts
Reply with quote

Hi,

I have a requirement like this.

I have a input file with the following records.

Code:

account no  amount
1               50
1               50


In output file i need to have a single records with amount added up.


Code:

account no  amount
1              100


Could you please suggest how this can be done using SORT?
your help would be highly apprciated.

Thanks

Shakti
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: Wed Feb 15, 2006 9:55 pm    Post subject:
Reply with quote

Assuming you're trying to get a total for each key (account number), you can use a DFSORT job like this:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1               50
1               50
2               20
2               40
3              150
3               40
3               80
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  SORT FIELDS=(1,1,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,1,
      TRAILER3=(1,1,13:TOT=(13,6,FS,EDIT=(IIIIIT))))
/*


SORTOUT will have:

Code:

1              100 
2               60 
3              270 


You could also do this using SORT and a SUM on ZD fields, but you'll need to use OUTREC to edit the SUM to suppress leading zeros.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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