Page 1 of 1

about sum fields

PostPosted: Thu Jul 26, 2012 3:36 pm
by cpzbn
Hi all
I met a problem when using DFSORT for 'sum fields', here is the my sample before.

File A includes the following records:
Line
Record 1: 23
Record 2: 456
Record 3: 1234
The file record length is 4 bytes(fill in space if the number not occupy all 4 bytes), i want to sum up all above records, then output to another file.

I use following syntax below first, but abend S0C7,
Method 1:
sum fields=(1,4,ZD)
then I tried following method, but the result seems not correct
Method 2:
sum fields=(1,4,BI)

Re: about sum fields

PostPosted: Thu Jul 26, 2012 5:31 pm
by BillyBoyo
You first specified Zoned Decimal, but the spaces tripped you up. Specifying Binary won't help, as the numbers are in character format and BI will treat them as enormous (or negative and with no obvious relation to your input).

Consult the manual. You have a "free format numeric". Yours is unsigned, so UFF. Look for examples of its use.

Re: about sum fields

PostPosted: Thu Jul 26, 2012 11:37 pm
by skolusu
cpzbn,

Use the following DFSORT JCL which will give you the desired results
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
23                                                             
456                                                             
1234                                                           
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL REMOVECC,NODETAIL,                                     
  TRAILER1=('SUM OF ALL RECORDS : ',TOT=(1,4,UFF,M10,LENGTH=8))
//*


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:

http://www.ibm.com/support/docview.wss? ... g3T7000080