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
 

 

Sum of field

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

New User


Joined: 14 Oct 2008
Posts: 65
Location: Pune

PostPosted: Fri Aug 19, 2011 7:24 pm    Post subject: Sum of field
Reply with quote

Hi,

I have file (FB,LREC=80). Values in this file are as below

111,222,333.44-
111,222,333.44
100,222,333.44-
111,111,222.44

Now I want to do summation of these values. When I used sum fields=(1,15,zd), it is giving S0C7 error. Can anybody tell how to achive this in one or 2 steps?
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Aug 19, 2011 7:35 pm    Post subject:
Reply with quote

Do you want sum to be done based on key field? what is it? where is the position of the key field in the file?

or you want to sum all the numbers to have one line output ?


In what format do you want output number? Is it the same way shown in input?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Aug 19, 2011 7:49 pm    Post subject:
Reply with quote

Shriram Jogdand,
Your input is SFF on which you can't directly perform SUM FIELDS . You would need to convert SFF to ZD and then perform SUM accordingly.

Refer to SUM Control Statement for more details on this.

Try something like below...
Code:
//SYSIN    DD *                                               
  INREC OVERLAY=(81:1,15,SFF,TO=ZD,LENGTH=11)                 
  SORT FIELDS=(17,1,SFF,A),EQUALS   --> I tested with 1 byte key at 17th position, you can change accordingly
  SUM FIELDS=(81,11,ZD)                                       
  OUTFIL BUILD=(81,11,ZD,EDIT=(III,III,IIT.TTS),SIGNS=(,,,-))
/*                                                           

Above example will suppress leading zeros, if you don't want leading zeros suppressed, use EDIT=(TTT,TTT,TTT.TTS).

Thanks,
Back to top
View user's profile Send private message
Shriram Jogdand

New User


Joined: 14 Oct 2008
Posts: 65
Location: Pune

PostPosted: Fri Aug 19, 2011 8:10 pm    Post subject: Sum of field
Reply with quote

Thanks sqlcode1..... icon_biggrin.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Aug 19, 2011 8:14 pm    Post subject:
Reply with quote

This is using OUTFIL SECTIONS....
Code:

//SYSIN    DD  *                                                     
  OPTION COPY                                                       
  INREC OVERLAY=(81:1,15,SFF,TO=ZD,LENGTH=11,92:X)                   
  OUTFIL REMOVECC,NODETAIL,SECTIONS=(92,1,TRAILER3=(1:TOT=(81,11,ZD,
  EDIT=(TTT,TTT,TTT.TTS),SIGNS=(,,,-)),16,65))                       
/*                                                                   
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Aug 19, 2011 8:26 pm    Post subject:
Reply with quote

Escapa,
Unless I misunderstood your solution for 92nd position, you could have used TRAILER1 or HEADER1 without SECTIONS. Was this field added for section break.?
Code:
//SYSIN    DD  *                                             
 OPTION COPY                                                 
 INREC OVERLAY=(81:1,15,SFF,TO=ZD,LENGTH=11)                 
 OUTFIL REMOVECC,NODETAIL,                                   
 TRAILER1=(TOT=(81,11,ZD,EDIT=(TTT,TTT,TTT.TTS),SIGNS=(,,,-)),
           16,65)                                             
/*                                                           

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

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Aug 19, 2011 8:32 pm    Post subject:
Reply with quote

Quote:

Unless I misunderstood your solution for 92nd position, you could have used TRAILER1 or HEADER1 without SECTIONS. Was this field added for section break.?


Yes you are right.. I added sections .. incase TS wanted to use key field there.. as it wasnt clearly mentioned...
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Aug 19, 2011 9:58 pm    Post subject: Reply to: Sum of field
Reply with quote

Shriram Jogdand,

The following DFSORT JCL will give you the desired results. I assumed that you want the output total to be the same format as input
Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                               
111,222,333.44-                                               
111,222,333.44                                               
100,222,333.44-                                               
111,111,222.44                                               
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  OUTFIL REMOVECC,NODETAIL,                                   
  TRAILER1=(TOT=(1,15,SFF,EDIT=(TTT,TTT,TTT.TTS),SIGNS=(,-)))
//*


Sqlcode1,Escapa,

You don't have to perform the conversion to ZD if you are using reporting feature TRAILER1 to get the TOTAL. You can use UFF, SFF formats directly on the TRAILER.
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


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