IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

summing of amount fields - kindly help!


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sallymary

New User


Joined: 18 Apr 2007
Posts: 4
Location: Chennai

PostPosted: Wed Apr 18, 2007 1:39 pm
Reply with quote

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
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Apr 18, 2007 1:51 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Sallymary

New User


Joined: 18 Apr 2007
Posts: 4
Location: Chennai

PostPosted: Wed Apr 18, 2007 3:41 pm
Reply with quote

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
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Apr 18, 2007 3:55 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Sallymary

New User


Joined: 18 Apr 2007
Posts: 4
Location: Chennai

PostPosted: Wed Apr 18, 2007 4:19 pm
Reply with quote

ok... william. Kindly help me icon_sad.gif
Back to top
View user's profile Send private message
Sallymary

New User


Joined: 18 Apr 2007
Posts: 4
Location: Chennai

PostPosted: Wed Apr 18, 2007 4:22 pm
Reply with quote

Can u give me an example for the above statement...??
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Apr 18, 2007 9:13 pm
Reply with quote

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)
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts Adding a trailer with record count an... JCL & VSAM 4
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
Search our Forums:

Back to Top