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

code to find the sum total for a particular field.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gskn4u
Currently Banned

New User


Joined: 29 Feb 2008
Posts: 25
Location: hyderabad

PostPosted: Thu May 22, 2008 6:48 pm
Reply with quote

Hi

Can anyone help me with the code to the following requirement:
I have a file with records
Code:

01  00000000042530405676  000001582
01  00000000042531167809  000000288
01  00000000042531234567  000000612
01  00000000042532059754  000001542
01  00000000042532422901  000005862
01  00000000042545624158  000000262
01  00000000042546018693  000000820
01  00000000042546410809  000000375
01  00000000042546631832  000000309
01  00000000042546902789  000000254
01  00000000042547253674  000002197
01  00000000042547370386  000000468
01  00000000042549774188  000000309
01  00000000042549995047  000000891
01  00000000042549998377  000000605


and i need the total sum of the 3rd field only.

Thanks,
Santosh
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu May 22, 2008 9:19 pm
Reply with quote

The following DFSORT JCL will give you the desired results

Code:

//STEP0300 EXEC PGM=ICEMAN               
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                           
----+----1----+----2----+----3----+----4--
01  00000000042530405676  000001582       
01  00000000042531167809  000000288       
01  00000000042531234567  000000612       
01  00000000042532059754  000001542       
01  00000000042532422901  000005862       
01  00000000042545624158  000000262       
01  00000000042546018693  000000820       
01  00000000042546410809  000000375       
01  00000000042546631832  000000309       
01  00000000042546902789  000000254       
01  00000000042547253674  000002197       
01  00000000042547370386  000000468       
01  00000000042549774188  000000309       
01  00000000042549995047  000000891       
01  00000000042549998377  000000605       
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  SORT FIELDS=COPY                       
  OUTFIL REMOVECC,NODETAIL,               
  TRAILER1=('TOTAL OF 3RD FIELD : ',     
            TOT=(27,09,ZD,M10,LENGTH=11)) 
//*                                       


Hope this helps...

cheer
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 May 22, 2008 9:19 pm
Reply with quote

You can use these DFSORT control statements:

Code:

  OPTION COPY                               
  OUTFIL REMOVECC,NODETAIL,                 
    TRAILER1=(TOT=(27,9,ZD,TO=ZD,LENGTH=10))


The output for your example would be:

0000016376

Adjust as needed.
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top