How get a count of records summed?



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

How get a count of records summed?

Postby RockinRiles » Thu Aug 16, 2012 12:55 am

Howdy ya'll!

I have an FB file which I'm sorting on cols 29-32.
I'm summing cols: 33-38, 39-44, 45-50.

I want output records to contain: sort value, each of 3 summed fields.

I'm able to do that with below:

//SYSIN DD *
SORT FIELDS=(29,4,PD,A)
SUM FIELDS=(33,6,39,6,45,6),FORMAT=PD
OUTREC FIELDS=(29,4,PD,
33,6,PD,
39,6,PD,
45,6,PD)
END

My question: How can I include a COUNT of the # of records that are included in the summing as the 5th column in my output record?

TIA!
User avatar
RockinRiles
 
Posts: 12
Joined: Thu Aug 16, 2012 12:35 am
Has thanked: 8 times
Been thanked: 0 time

Re: How get a count of records summed?

 

Re: How get a count of records summed?

Postby BillyBoyo » Thu Aug 16, 2012 1:23 am

If you add a constant value of one to the end of each record, and include that in the SUM, that should do it.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How get a count of records summed?

Postby RockinRiles » Thu Aug 16, 2012 1:29 am

Thanx but, I can't modify this file.
User avatar
RockinRiles
 
Posts: 12
Joined: Thu Aug 16, 2012 12:35 am
Has thanked: 8 times
Been thanked: 0 time

Re: How get a count of records summed?

Postby BillyBoyo » Thu Aug 16, 2012 4:23 am

Well, you can (to do what is needed) without any changes to the file itself.

You can amend records within Sort itself, and that is what you need here.

  INREC OVERLAY=(80:C'000001')


This assumes you lrecl is 80, change if necessary. It increases the length of each record, within the sort, by six bytes, which are set to that constant value.

SUM on the field as well.

The final output has to include the count anyway, doesn't it :-)

These users thanked the author BillyBoyo for the post:
RockinRiles (Thu Aug 16, 2012 7:39 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How get a count of records summed?

Postby RockinRiles » Thu Aug 16, 2012 7:06 am

BillyBoyo wrote:Well, you can (to do what is needed) without any changes to the file itself.

You can amend records within Sort itself, and that is what you need here.

  INREC OVERLAY=(80:C'000001')


This assumes you lrecl is 80, change if necessary. It increases the length of each record, within the sort, by six bytes, which are set to that constant value.

SUM on the field as well.

The final output has to include the count anyway, doesn't it :-)


Billy,

This looks very doable. I will try it out when I get in the office tomorrow.

For my info, if the lrec is actually 80 chars, does this change the 80th byte to "000001", pos 80-85?, (in the virtual world natch) such that it's not available to me for evaluating in this process?
i.e. Say the 80th char is part of a field I'm sorting or summing on. Would I need to use positions in the record for the OVERLAY that I'm not currently using? Like an address field?

In this case, I'm not using the 80th byte so, your solution just may do the trick.

I'll let you know.

Thanx!
User avatar
RockinRiles
 
Posts: 12
Joined: Thu Aug 16, 2012 12:35 am
Has thanked: 8 times
Been thanked: 0 time

Re: How get a count of records summed?

Postby dick scherrer » Thu Aug 16, 2012 8:28 am

Hello and welcome to the forum,

Even if you are using pos 80 as real data, you should still do as BB suggests. Keep in mind that you are only using an intermediate set of data and the "extra" 1 will NOT be placed in the output file.
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
RockinRiles (Thu Aug 16, 2012 7:40 pm)
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How get a count of records summed?

Postby NicC » Thu Aug 16, 2012 8:31 am

This is NOT a JCL topic but a sort topic. Moved to DFSort. If SYNCSORT is used then it will be moved again.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
RockinRiles (Thu Aug 16, 2012 7:39 pm)
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: How get a count of records summed?

Postby BillyBoyo » Thu Aug 16, 2012 11:04 am

RockinRiles,

For an 80-byte record the OVERLAY should have been 81:

If you have bytes on your input record which are not used in your output file, then they can be utilised.

If you only want your Key, three amounts and the count, you can BUILD a record to reflect that in INREC, and only that data then goes into the actual sort, reducing run-time, work-file use.

If you need all the data from the input, you have to extend the record, even if only temporarily - although your count has to go "somewhere" :-)

These users thanked the author BillyBoyo for the post:
RockinRiles (Thu Aug 16, 2012 7:39 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How get a count of records summed?

Postby RockinRiles » Thu Aug 16, 2012 7:38 pm

You guys are Da Bomb!!!
That worked great!

Here's my JCL:
//SYSIN    DD *
    SORT FIELDS=(29,4,PD,A)
    INREC OVERLAY=(81:C'000001')
    SUM FIELDS=(33,6,PD,39,6,PD,45,6,PD,81,6,ZD)
    OUTREC FIELDS=(29,4,PD,
                   33,6,PD,
                   39,6,PD,
                   45,6,PD,
                   81,6,ZD)
  END


Here's a sample of the output file records.
*Column names obviously not in output file. LOL!

  Julian
   Date ........ Amt1 ......  Amt2 .....  Amt3 .. Count
 2012170   670340109   344426809   309119158   1629 ,
 2012171  1126832318    72207780    43737541   9444 ,
 2012172  1302710541    48816247   100536950  18909 ,


You guys are now on my Christmas card list!

Thanks for this forum,

Rockin Riles

PS - This probably does belong in the Syncsort section. Sorry bout that.
User avatar
RockinRiles
 
Posts: 12
Joined: Thu Aug 16, 2012 12:35 am
Has thanked: 8 times
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post