|
View previous topic :: View next topic
|
| Author |
Message |
Shriram Jogdand
New User

Joined: 14 Oct 2008 Posts: 65 Location: Pune
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
Shriram Jogdand
New User

Joined: 14 Oct 2008 Posts: 65 Location: Pune
|
|
|
|
Thanks sqlcode1.....  |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| 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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|