SORT SUM

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

SORT SUM

Post by SRI123 » Wed Aug 12, 2009 12:37 pm

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)

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Wed Aug 12, 2009 1:30 pm

SRI123,

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

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Wed Aug 12, 2009 3:44 pm

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.

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Wed Aug 12, 2009 4:25 pm

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
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Wed Aug 12, 2009 4:36 pm

Thank you.
And does this sysntax is valid for packed data also? for packed I'm not getting correct output. Field declaration is S9(9).

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Wed Aug 12, 2009 5:12 pm

SRI123,
And does this sysntax is valid for packed data also?
No, it's NOT. As per your original problem, your input file has ZD data. The solution can vary based on the field format.
for packed I'm not getting correct output
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.
Arun

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Wed Aug 12, 2009 5:21 pm

FIELD format is ==> SV99 PD 15 2
data is like this
05
1C

06
5C

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Aug 12, 2009 8:35 pm

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:

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

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Thu Aug 13, 2009 10:09 am

Thank you Frank

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:27 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others