issues with a sort



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

issues with a sort

Postby migusd » Fri Oct 10, 2014 3:53 am

Hi all,
I need some guidance on a small report.
I have an input file which contains around 2 million records. File is about 115 in record length.
I am sorting by 2 fields 1 byte each.
I am summing up by a third field, and need to count the records by sort by fields, keeping subtotals by the inner field and totals by the outer by field.

My issue is that,
1) Count is giving always 1 as result, and is wrong
2) Is adding an extra record to put the count result.

how can I solve this?
I am assuming that the trailer3 I am using is wrong.
Or maybe is when it executes first the sum deletes the duplicate records and by the time it gets to count them is only 1 of them.
How can I force the count result to the end of the same record?

I tried using OUTREC, but how can I specify the name of the count field?

Here is my code
  INREC FIELDS=(015,050,       ID                 
                081,001,               TYPE               
                085,003,               H CODE                 
                096,008,               ENTITIES #               
                105,010)               DATE                     
  SORT FIELDS=(81,1,A,85,03,A),FORMAT=CH           
   SUM FIELDS=(96,8,ZD)                           
    OUTFIL REMOVECC,                       
           SECTIONS=(81,1,                         
                     85,3,                         
                     TRAILER3=(81,1,               
                               83,3,               
                                '=',               
                                COUNT=(M11,       
                                       LENGTH=08)))


Thanks

Miguel

Code'd
migusd
 
Posts: 40
Joined: Tue Dec 01, 2009 9:26 pm
Has thanked: 6 times
Been thanked: 0 time

Re: issues with a sort

Postby BillyBoyo » Fri Oct 10, 2014 4:27 am

Better to use BUILD than FIELDS, although they are completely equivalent. using BUILD is clearer (BUILD always does the same thing, FIELDS does different things depending on context it is used in).

Yes, your SUM statement is getting rid of all but one record for each key combination, so your COUNT will always be one.

The TRAILER3 will always create an extra "line" (record) when you have data. If you just want "total lines", add NODETAIL to your OUTFIL statement.

I don't understand how your SORT and SUM work, as you have used INREC to cut the records down to 72 bytes of data. Are you sure you are showing the Control Cards that you ran?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: issues with a sort

Postby migusd » Fri Oct 10, 2014 7:55 pm

Thank you Billy
Wouldn't be nice to allow count the records at the same time as SUM?

sorry. I mixed the control cards I used.
Here are the cards I used for my test.
  SORT FIELDS=(81,1,A,85,03,A),FORMAT=CH           
   SUM FIELDS=(96,8,ZD)                           
    OUTFIL REMOVECC,NODETAIL,                     
           SECTIONS=(81,1,                         
                     85,3,                         
                     TRAILER3=(81,1,               
                               83,3,               
                                '=',               
                                COUNT=(M11,       
                                       LENGTH=08)))


Here is my another thing I didn't get.
As you can see the input file length is 114.
running it without outrec, I got garbage for the extra fields I don't needed.
So, in order to rid of those fields I turned to INREC, as follows
  INREC FIELDS=(015,050, ID                 
                081,001, TYPE               
                085,003, H CODE                 
                096,008, ENTITLES #               
                105,010) DATE
 SORT... (the same as above)  + trailer3
 OUTFIL ...
            TRAILER3=(85,3,               
                            81,1,               
                                 '=',               
                          COUNT=(M11,       
                          LENGTH=08)))


and got a nasty
WER257I INREC RECORD LENGTH = 72
where 72 is the total length for the fields I included in INREC
I guess I need to read more about INREC. Was expecting to use input file length and selecting only a few fields.

running the process with NODETAIL, effectively creates an empty file.

I guess I should have to run separate process one for the sum, and another one for the count. Then merge them together.
Any other way of solving it?

Thanks

Code'd
migusd
 
Posts: 40
Joined: Tue Dec 01, 2009 9:26 pm
Has thanked: 6 times
Been thanked: 0 time

Re: issues with a sort

Postby migusd » Fri Oct 10, 2014 8:16 pm

I understand now the reason for the WER257I Record Length error.
I didn't adjust the sort/sum control cards to adjust to the new length.

thanks
migusd
 
Posts: 40
Joined: Tue Dec 01, 2009 9:26 pm
Has thanked: 6 times
Been thanked: 0 time

Re: issues with a sort

Postby Terry Heinze » Fri Oct 10, 2014 8:34 pm

Please use Code tags for better readability:

SORT FIELDS=(81,1,A,85,03,A),FORMAT=CH
SUM FIELDS=(96,8,ZD)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(81,1,
85,3,
TRAILER3=(81,1,
83,3,
'=',
COUNT=(M11,
LENGTH=08)))
.... Terry
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: issues with a sort

Postby migusd » Fri Oct 10, 2014 9:31 pm

yes Terry
here it is again... to summarize I would like to sum up on pos 55,
...and at the same time get the number of records before being squeezed out by sum.

Something like this.
  INREC FIELDS=(015,050, ID                 
                081,001, TYPE               
                085,003, H CODE                 
                096,008, ENTITLES #               
                105,010) DATE                     
  SORT FIELDS=(51,1,A,52,03,A),FORMAT=CH           
   SUM FIELDS=(55,8,ZD)                           
    OUTFIL REMOVECC,NODETAIL,                     
           SECTIONS=(51,1,                         
                     52,3,                         
                     TRAILER3=(51,1,               
                               53,3,               
                                '=',               
                                COUNT=(M11,       
                                       LENGTH=08)))

Thanks Terry

Code'd again
migusd
 
Posts: 40
Joined: Tue Dec 01, 2009 9:26 pm
Has thanked: 6 times
Been thanked: 0 time

Re: issues with a sort

Postby BillyBoyo » Fri Oct 10, 2014 9:35 pm

How many records can you have with the same key? You add a new, temporary, field of sufficient size with a value of one. Update the SUM to include that field. You then get the totals and a count.

These users thanked the author BillyBoyo for the post:
migusd (Fri Oct 10, 2014 9:41 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: issues with a sort

Postby migusd » Fri Oct 10, 2014 10:52 pm

Thanks Billy...
That made the difference...!!!
migusd
 
Posts: 40
Joined: Tue Dec 01, 2009 9:26 pm
Has thanked: 6 times
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post