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

Sum of field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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: 577
Location: USA

PostPosted: Fri Aug 19, 2011 7:49 pm
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
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
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: 577
Location: USA

PostPosted: Fri Aug 19, 2011 8:26 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top