SORT SUM
Moderators: Frank Yaeger, Moderator Group
SORT SUM
I want to sum the amounts that are at position 10,12,ZD. I want to sum all the amounts. And out should contain only the total amount. I tried with the below statement, but I'm not getting the sum, it is only displaying all the records in the output. Please help me.
OPTION COPY
SUM FIELDS=(10,12,ZD)
OPTION COPY
SUM FIELDS=(10,12,ZD)
SRI123,
Welcome to the forums. Try this one.
Welcome to the forums. Try this one.
Code: Select all
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN = Input file
//SORTOUT DD DSN = Output file
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('TOTAL=',TOT=(10,12,ZD,M11,LENGTH=12))
Arun
Thank you arcvns for qucik reply. This is working fine. My field declaration is S9(9)V99. So the out put is displaying without decimal. Can I get with decimal out put with sign like +123.45 or -123.45. And does this sysntax is valid for packed data also? for packed I'm not getting correct output. Field declaration is S9(9).
Last edited by SRI123 on Wed Aug 12, 2009 4:29 pm, edited 1 time in total.
Change your OUTFIL statement like this to display the sign as well. AFAIK s9(9)v99 would occupy only 11 bytes.
Code: Select all
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('TOTAL=',TOT=(10,11,ZD,EDIT=(STTTTTTTTT.TT),SIGNS=(+,-)))
Arun
SRI123,
No, it's NOT. As per your original problem, your input file has ZD data. The solution can vary based on the field format.And does this sysntax is valid for packed data also?
The solution provided was for ZD input. Now what exactly is your field format? Is it ZD? Or PD? What is its length? How does it look like? If possible provide some sample data.for packed I'm not getting correct output
Arun
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
I believe that data is equivalent to a 2-byte PD field starting at position 15 interpreted as a sd.dd value.
A total for that value could overflow sd.dd so you would probably want to display it as a larger values, something like sdddd.dd depending on what you want the output value to look like. As an example, you could use these DFSORT statements:
A total for that value could overflow sd.dd so you would probably want to display it as a larger values, something like sdddd.dd depending on what you want the output value to look like. As an example, you could use these DFSORT statements:
Code: Select all
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('TOTAL=',TOT=(15,2,PD,EDIT=(SIIIT.TT),SIGNS=(+,-)))
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page