Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Sallymary

New User

Joined: 18 Apr 2007
Posts: 4
Location: Chennai

Posted: Wed Apr 18, 2007 1:39 pm    Post subject: summing of amount fields - kindly help!

To sum amount fields the condition used are

 Code: SORT FIELDS=(1201,6,CH,A)            INCLUDE COND=(1120,3,CH,EQ,C'90 ',OR,               1120,3,CH,EQ,C'91 ',OR,               1120,3,CH,EQ,C'92 ',OR,               1120,3,CH,EQ,C'94 ',OR,               1120,3,CH,EQ,C'90R',OR,               1120,3,CH,EQ,C'90X',OR,               1120,3,CH,EQ,C'91F',OR,               1120,3,CH,EQ,C'94Y',OR,               1120,3,CH,EQ,C'95X')    SUM  FIELDS=(509,10,ZD)              OUTREC FIELDS=(1201,6,6C' ',509,10,ZD,M4)

The output generated is having more than one record
File1
 Code: CTSP        +80,931,179.11                                                      CTSP        +75,103,424.97                                                      CTSP        +91,613,505.83

But the required output is only a single record like

File2
 Code: CTSP        247648109.91

When we sum up all the amounts in file1 we get the total of file2
but in the former it is getting split

William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

Posted: Wed Apr 18, 2007 1:51 pm    Post subject: Re: summing of amount fields - kindly help!

 Sallymary wrote: The output generated is having more than one record But the required output is only a single record like When we sum up all the amounts in file1 we get the total of file2 but in the former it is getting split
You specify only 10 digits for the total, so SORT is giving you the best it can without truncating the results. If your final total requires 11, maybe you should change your OUTREC.
Sallymary

New User

Joined: 18 Apr 2007
Posts: 4
Location: Chennai

 Posted: Wed Apr 18, 2007 3:41 pm    Post subject: I tried increasing OUTREC field by OUTREC FIELDS=(1201,6,6C' ',509,12,ZD,M4) The output is CTSP +8,093,117,911.00 CTSP +7,510,342,497.00 CTSP +9,161,350,583.00 But the output still remained the same
William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

 Posted: Wed Apr 18, 2007 3:55 pm    Post subject: Opps, forgot about the SUM field. From the DFSORT manual: If overflow might occur during summation, INREC can be used to create a larger SUM field in the reformatted input record (perhaps resulting in a larger record for sorting or merging) so that overflow does not occur.
Sallymary

New User

Joined: 18 Apr 2007
Posts: 4
Location: Chennai

 Posted: Wed Apr 18, 2007 4:19 pm    Post subject: ok... william. Kindly help me
Sallymary

New User

Joined: 18 Apr 2007
Posts: 4
Location: Chennai

 Posted: Wed Apr 18, 2007 4:22 pm    Post subject: Can u give me an example for the above statement...??
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Wed Apr 18, 2007 9:13 pm    Post subject:

Sallymary,

Here's a DFSORT job that will do what you asked for. Note that we add a character 0 (C'0') before your 10 byte ZD field to make it an 11 byte ZD field so it won't overflow.

 Code: //S1    EXEC  PGM=ICEMAN //SYSOUT    DD  SYSOUT=* //SORTIN DD DSN=...  input file //SORTOUT DD DSN=...  output file //SYSIN    DD    *   INCLUDE COND=(1120,3,CH,EQ,C'90 ',OR,                 1120,3,CH,EQ,C'91 ',OR,                 1120,3,CH,EQ,C'92 ',OR,                 1120,3,CH,EQ,C'94 ',OR,                 1120,3,CH,EQ,C'90R',OR,                 1120,3,CH,EQ,C'90X',OR,                 1120,3,CH,EQ,C'91F',OR,                 1120,3,CH,EQ,C'94Y',OR,                 1120,3,CH,EQ,C'95X')   INREC FIELDS=(1201,6,13:C'0',509,10)   SORT FIELDS=(1,6,CH,A)   SUM  FIELDS=(13,11,ZD)   OUTREC FIELDS=(1,12,13,11,ZD,M4) /*
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us