Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sum of records on a field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sum of records on a field
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

Senior Member


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

PostPosted: Tue May 24, 2011 6:31 pm    Post subject:
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

Senior Member


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

PostPosted: Tue May 24, 2011 6:58 pm    Post subject:
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 Moderator


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

PostPosted: Tue May 24, 2011 11:18 pm    Post subject:
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 Moderator


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

PostPosted: Tue May 24, 2011 11:20 pm    Post subject:
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

Senior Member


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

PostPosted: Wed May 25, 2011 3:09 pm    Post subject:
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    Post subject: Reply to: Sum of records on a field
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    Post subject: RE:Sum of records on a field
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 Moderator


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

PostPosted: Fri May 27, 2011 9:03 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us