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

Sum of records on a field


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

New User


Joined: 14 Oct 2008
Posts: 65
Location: Pune

PostPosted: Tue May 24, 2011 5:25 pm
Reply with quote

Hi,

I searched the mainframe forum but was not able to locate post which have both TRAILER3 and COUNT

My requirement is as follows.

There is one control card that is running in production

SORT FIELDS=(3,2,CH,A,101,6,CH,A)
OUTFIL FILES=1,NODETAIL,
INCLUDE=(1,2,ZD,EQ,00,OR,107,1,CH,EQ,C'C'),
SECTIONS=(101,6,TRAILER3=(101,6,COUNT)),REMOVECC

This card is doing summation of the records depending on the field (whcih is starting at 101 and having length 6 byte). If more than one record will have same value then there will be summation which is coming in the o/p file as 6 bytes.

The problem is that, if sum of such records is more than 6 byte then it is getting truncated. Can we increase the length here in sort card so that sum should not truncate?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue May 24, 2011 6:31 pm
Reply with quote

Your explantion is fishy, however, what you've asked for, to do that, you can use edit-mask:
Code:
SECTIONS=(101,6,TRAILER3=(101,6,COUNT=(M11,LENGTH=n))),REMOVECC
replace "n" with desired number.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue May 24, 2011 6:58 pm
Reply with quote

Frank,
Quote:
The problem is that, if sum of such records is more than 6 byte then it is getting truncated.
Is not COUNT a number which will be a right-justified 8-digit field with leading zeros suppressed?
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: Tue May 24, 2011 11:18 pm
Reply with quote

Code:

   SECTIONS=(101,6,TRAILER3=(101,6,COUNT)),REMOVECC


Quote:
This card is doing summation of the records depending on the field (whcih is starting at 101 and having length 6 byte). If more than one record will have same value then there will be summation which is coming in the o/p file as 6 bytes.


No, that's NOT what this card is doing. What it's actually doing is creating a section trailer with positions 101-106 from the last record in the section followed by the COUNT of records in the section. If you want to sum the field at 101-106, you would use something like this:

Code:

  SORT FIELDS=(3,2,CH,A,101,6,CH,A)
  OUTFIL FILES=1,NODETAIL,REMOVECC,
  INCLUDE=(1,2,ZD,EQ,00,OR,107,1,CH,EQ,C'C'),
   SECTIONS=(101,6,TRAILER3=(TOT=(101,6,ZD,M10,LENGTH=10)))
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: Tue May 24, 2011 11:20 pm
Reply with quote

Quote:
Is not COUNT a number which will be a right-justified 8-digit field with leading zeros suppressed?


Yes, that's what COUNT does. The OP is NOT doing what he thinks he is. See my previous post for details.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed May 25, 2011 3:09 pm
Reply with quote

Thank you, Frank.
Back to top
View user's profile Send private message
Shriram Jogdand

New User


Joined: 14 Oct 2008
Posts: 65
Location: Pune

PostPosted: Thu May 26, 2011 11:39 am
Reply with quote

Hi,

Before changes, my o/p file was coming something like this

Name11 Total01
--------- ------------
ABCDEF 10203040
LMNOPQ 30504070

i.e Name11 as of 6 bytes and count(i.e total01) as of 8 bytes. I ran the job with the above suggested solution. The length of Total01 is increased but not displaying Name11 in o/p file. I want both the fields in o/p file with increased length of Total01 to 9 bytes instead of 8 bytes.
Back to top
View user's profile Send private message
Shriram Jogdand

New User


Joined: 14 Oct 2008
Posts: 65
Location: Pune

PostPosted: Thu May 26, 2011 12:09 pm
Reply with quote

I got the solution.

The code should be changed as below

SECTIONS=(101,6,TRAILER3=(101,6,COUNT=(M10,LENGTH=9)))

Thanks for the suggestions.
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: Fri May 27, 2011 9:03 pm
Reply with quote

You really should try harder to get your terminology right.

You apparently want a count of the number of records with each key. That is NOT the same as saying you are "doing summation of the records depending on the field (whcih is starting at 101 and having length 6 byte)". The latter would imply using TOTAL, not COUNT.

In the future, please try harder to explain clearly what you want to do and include an example of input and expected output. That will save everyone (including you) time.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top