Summation of an input field using SORT

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Summation of an input field using SORT

Post by goldyroshan » Wed Apr 16, 2014 10:42 am

My input file has 614 records. I want to sum one field at 3273 rd position (length = 12). It is a S9(10)V9(2)

I tried using the below sort card, but I am not getting the desired output - which should be one row in output file showing me the summation of the above field.
Instead I am getting 614 rows in output file.


SORT FIELDS=(3809,9,CH,A) -> another field having values as Alphabets
SUM FIELDS=(3273,12,ZD) -> desired field to be added

Please provide the sort card.
I even tried using BI instead of ZD, but same result.
Logically yours,
:-) GRS :-)

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Wed Apr 16, 2014 11:14 am

I tried the below sort card & it worked -

OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOT=(3273,12,ZD,TO=ZD,LENGTH=12))

I did get a trailer record with a value, but I would want to see the value in displayable format so that I can directly export it to xls. Please help with that.
Logically yours,
:-) GRS :-)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Apr 16, 2014 11:54 am

SUM only gives a sum for value with duplicate key(s), the key(s) being those defined in the SORT statement.. You seem to want a total for a file, so SUM is no good to you for that.

What do you consider non-displayable about the value you received from TRAILER1?

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Fri May 02, 2014 1:42 pm

Here is what I used finally to get the desired sum -

OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOT=(3273,12,ZD,TO=FS,LENGTH=12))

Thx William for replying to my posts!
Logically yours,
:-) GRS :-)

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