Posted: Wed Sep 19, 2007 3:23 am Post subject: Need sum of a column and number of columns.
Hi,
I have a FB file of rec length 50. The sample records are given below. Now I need a JCl to give the sum of the field in bold and the count of number of records. I can use DFsort and SYNCsort only.
Both of your codes worked fine.. But can you pls tell if I can get the output of count into a file rather than sysout..
And in sort why is the TOT having fields from 81 position. Because M using files for sortin and sortout where the lenth is 50. M getting error if I use the code for files as ther is no 81 position in either of my files.
Both of your codes worked fine.. But can you pls tell if I can get the output of count into a file rather than sysout..
And in sort why is the TOT having fields from 81 position. Because M using files for sortin and sortout where the lenth is 50. M getting error if I use the code for files as ther is no 81 position in either of my files.
thanks,
Suresh.
Suresh,
If you are getting error if you use 81, then replace 80 by 50 and 81 by 51 as below. It works fine.
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(01,50,
27,07, $ AMT1 BEFORE DECIMAL
35,02) $ AMT1 AFTER DECIMAL
OUTFIL REMOVECC,
OUTREC=(01,50),
TRAILER1=(37C'-',/,
'SUM OF EACH ITEM: ',
TOT=(51,09,ZD,EDIT=(IIIIIIT.TT)),/,
37C'-')
/*
If you want the count to be written to an output file, you can use the below code:
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Sep 19, 2007 9:00 am Post subject:
suresh_d,
The following DFSORT 1 step JCL will give you the count of records as well as the total of column4
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
TRAILER1=(37C'*',/,
'TOTAL NO OF RECORDS : ',
COUNT=(M10,LENGTH=10),/,
'SUM OF ALL RECORDS : ',
TOT=(27,10,UFF,EDIT=(IIIIIIIIIT.TT)),/,
37C'*')
/*
The output is :
Code:
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
234526.05.2007 0123457.11 0012345.22
*************************************
TOTAL NO OF RECORDS : 4
SUM OF ALL RECORDS : 49380.88
*************************************
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Sep 19, 2007 10:05 am Post subject:
Quote:
Now, if you people dont get irritated.. can you please tell how to write the output of above jcl without input record's in the o/p file.
suresh_d,
use the following control cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL NODETAIL,REMOVECC,
TRAILER1=(37C'*',/,
'TOTAL NO OF RECORDS : ',
COUNT=(M10,LENGTH=10),/,
'SUM OF ALL RECORDS : ',
TOT=(27,10,UFF,EDIT=(IIIIIIIIIT.TT)),/,
37C'*')
/*
I need to format the O/P still. The total amount needs to have 9 decimal and 9 integer part. I jus chaged the edit part to EDIT=(IIIIIIIIT.TTTTTTTTT). But it is not working. Can you please help.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Sep 20, 2007 7:42 am Post subject:
Quote:
need to format the O/P still. The total amount needs to have 9 decimal and 9 integer part. I jus chaged the edit part to EDIT=(IIIIIIIIT.TTTTTTTTT).
suresh_d,
You shouldn't get any error with that edit mask. When ever you say something does not work you need to post the complete sysout messages.
Try these control cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL NODETAIL,REMOVECC,
TRAILER1=(37C'*',/,
'TOTAL NO OF RECORDS : ',
COUNT=(M10,LENGTH=10),/,
'SUM OF ALL RECORDS : ',
TOT=(27,10,UFF,EDIT=(IIIIIIIIIT.TTTTTTTTT)),/,
37C'*')
/*
Also you say you want 9 integer numbers and 9 decimal numbers which is a total 19 bytes (including the decimal dot) it does not make sense. Remember that you are summing only a 10 byte field and you want a 19 byte output field? If you need 9 decimals then the output sum be as follows
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