MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SUM the total amount

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Mon Oct 06, 2008 4:17 am    Post subject: SUM the total amount Reply with quote

Hi

I want to sum the amount and write into o/p file based on the account numer viz.

Code:
IP
A/c        amount
123456  1000
123456  1500
123457  1000
123459  4000
123457  1000
123459  5000
123459  6709
123457  1000

OP
123456  1000
123456  1500
Total SUM=2500
123457  1000
123457  1000
123457  1000
Total SUM=3000
123459  4000
123459  5000
123459  6709
Total SUM=15709


Please help on this.

Thanks in Advance
Back to top
View user's profile Send private message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Mon Oct 06, 2008 5:52 am    Post subject: Reply with quote

I want to achieve through sort utilities.


Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Oct 06, 2008 11:12 am    Post subject: Reply with quote

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

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
123456  1000
123456  1500
123457  1000
123459  4000
123457  1000
123459  5000
123459  6709
123457  1000
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=(1,6,CH,A)
  OUTFIL REMOVECC,
    SECTIONS=(1,6,
      TRAILER3=(C'TOTAL SUM=',
        TOT=(9,4,ZD,TO=ZD,LENGTH=5)))
/*


SORTOUT will have:

Code:

123456  1000       
123456  1500       
TOTAL SUM=02500     
123457  1000       
123457  1000       
123457  1000       
TOTAL SUM=03000     
123459  4000       
123459  5000       
123459  6709       
TOTAL SUM=15709     


I used TO=ZD,LENGTH=5 for the SUM value. If you want the SUM value in some other form, show exactly what you want for the TOTAL SUM= line, keeping in mind the largest value you can have for the totals (5 digits in your example).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group