sorting records inside group/set help needed



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

sorting records inside group/set help needed

Postby akanchu » Wed Jun 08, 2016 2:53 am

My input file is a VB file with lrecl 1452.

first 10 digits are set-id . The number of records in one set are variable.
16 pos - 3 bytes are type of record. -- 010 is the person info.
32 pos - 2 bytes are the role of the person

if the role is 02 (pos 32) - pos 107 - 3 bytes has the allocation.


----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2
          000000000000000000000ANN
          00000000300000100000001N
          00000000300000200000002N
          00000000400000100000001N
          00000000400000200000002N
BEER11440000000101000000100000003YPP          Chicken                  J        
BEER11440000000201000000200000007YPNBRUCE D JENNER                            
BEER11440000000301000000300000001NPP          Chicken                  J        
BEER11440000000401000000400000002NPP          Alice                    J              JENNER              030
BEER11440000000501000000500000002NPP          Alexis                   E              JENNER              070        
BEER11440000000601000000600000012NPNEstate of Chicken J Perdue                    
BEER11440000000701000000700000014NPP          Chicken                  J        
BEER114400000008015000001000000522738130                         0100  NNNNNNNN0
BEER114400000009015000002000000475848840                         0100  NNNNNNNN0
BEER114400000010020000001000000522738130                         1200203000000{0
BEER11440000001131000000100000002D20150528000000000015692{000000000000000{      
BEER11440000001231000000200000002D20150628000000000015692{000000000000000{      
BEER1144000000134000000010000009920150609201606080000000020150609208206
NEAT26691000000101000000100000003YPP          Andrew                                  Bourdean                    
NEAT26691000000201000000200000007YPP          MARK                                    Bourdean
NEAT26691000000301000000300000001NPP          Andrew                                  Bourdean                    
NEAT26691000000401000000400000001NPP          Christianne              
NEAT26691000000501000000500000012NPNBourdean Kids Irrev Trust                        
NEAT26691000000601000000600000002NPP          Christianne                             Bourdean            100
NEAT26691000000701000000700000014NPP          Alan and Christianne                    Bourdean
NEAT266910000008015000001000000293606780                         0100  
NEAT266910000009015000002000000570258837                         0100  
NEAT266910000010020000001000000293606780                         120020
NEAT266910000011020000002000000565532184                         120020
          000000999000000000000000000000030      

 


I want to keep the records in the set togather.
With that said, want to sort the
(a) Name Asc (starting 47 - 60 chars.)
(b) Allocation desc - (starting 107 - 3 bytes)

expected output :

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2
          000000000000000000000ANN
          00000000300000100000001N
          00000000300000200000002N
          00000000400000100000001N
          00000000400000200000002N
BEER11440000000101000000100000003YPP          Chicken                  J        
BEER11440000000201000000200000007YPNBRUCE D JENNER                            
BEER11440000000301000000300000001NPP          Chicken                  J        
BEER11440000000501000000500000002NPP          Alexis                   E              JENNER              070        
BEER11440000000401000000400000002NPP          Alice                    J              JENNER              030
BEER11440000000601000000600000012NPNEstate of Chicken J Perdue                    
BEER11440000000701000000700000014NPP          Chicken                  J        
BEER114400000008015000001000000522738130                         0100  NNNNNNNN0
BEER114400000009015000002000000475848840                         0100  NNNNNNNN0
BEER114400000010020000001000000522738130                         1200203000000{0
BEER11440000001131000000100000002D20150528000000000015692{000000000000000{      
BEER11440000001231000000200000002D20150628000000000015692{000000000000000{      
BEER1144000000134000000010000009920150609201606080000000020150609208206
NEAT26691000000101000000100000003YPP          Andrew                                  Bourdean                    
NEAT26691000000201000000200000007YPP          MARK                                    Bourdean
NEAT26691000000301000000300000001NPP          Andrew                                  Bourdean                    
NEAT26691000000401000000400000001NPP          Christianne              
NEAT26691000000501000000500000012NPNBourdean Kids Irrev Trust                        
NEAT26691000000601000000600000002NPP          Christianne                             Bourdean            100
NEAT26691000000701000000700000014NPP          Alan and Christianne                    Bourdean
NEAT266910000008015000001000000293606780                         0100  
NEAT266910000009015000002000000570258837                         0100  
NEAT266910000010020000001000000293606780                         120020
NEAT266910000011020000002000000565532184                         120020
          000000999000000000000000000000030
 


I put in a seq# and name and alloc togather and tried to sort it. It pushed the 02 record that had the allocation towards the bottom.

Sample sysin

//SYSIN    DD  *                                                      
   INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,110Z,5)),                      
         IFTHEN=(WHEN=INIT,                                          
                 OVERLAY=(5:115,10,15:SEQNUM,8,ZD,23:87Z)),          
         IFTHEN=(WHEN=(131,3,ZD,EQ,000,OR,131,3,ZD,EQ,001,OR,        
                       131,3,ZD,EQ,002,OR,131,3,ZD,EQ,003,OR,        
                       131,3,ZD,EQ,004),                              
                 OVERLAY=(5:C'AAAAAAAAAA')),                          
         IFTHEN=(WHEN=(131,3,ZD,EQ,010,AND,146,2,ZD,EQ,02),
                 OVERLAY=(23:161,60,221,3)),    
         IFTHEN=(WHEN=(131,3,ZD,EQ,999),                              
                 OVERLAY=(5:C'ZZZZZZZZZZ'))                          
   SORT FIELDS=(5,10,CH,A,                                            
                23,60,CH,A,    
                25,3,ZD,D,    
                15,8,ZD,A)    
   OUTREC BUILD=(1,4,111)        
/*
 


What else should I do to keep the set to gather and order other than the allocation records.
Please guide.
Thanks
AK
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: sorting records inside group/set help needed

Postby BillyBoyo » Wed Jun 08, 2016 11:26 am

You need to be able to identify the first record of your set (group).

Use IFTHEN=(WHEN=GROUP to identify that, and PUSH to extend the records with an ID which is long enough to hold all your sets. Then make the ID the first part of the SORT key, and specify EQUALS for the SORT. For now I'll assume that the rest of your idea is about right for now.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: sorting records inside group/set help needed

Postby akanchu » Wed Jun 08, 2016 7:33 pm

I am using the 10 digits to group it as a set.

But the internal sort of the name+allocation, pushes it down.

Thanks
AK
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: sorting records inside group/set help needed

Postby BillyBoyo » Thu Jun 09, 2016 12:50 am

Well, you have no WHEN=GROUP, so you are not grouping, even if you think you are.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: sorting records inside group/set help needed

Postby akanchu » Thu Jun 09, 2016 1:57 am

ahh.. did not think it that way.. will try that and get back.

Thanks
AK
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: sorting records inside group/set help needed

Postby akanchu » Fri Jun 10, 2016 12:59 am

So I added

IFTHEN=(WHEN=GROUP,                              
        BEGIN=(129,2,ZD,EQ,01,OR,131,2,ZD,EQ,00),
        PUSH=(15:ID=8)),                          
 

and changed the SYSIN to :

   SORT FIELDS=(15,8,CH,A,                                            
                23,60,CH,A,    
                25,3,ZD,D)
   OUTREC BUILD=(1,4,111)  
 


But still the same result, moved the rows that had allocated to end of the same set.
Thanks
AK
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: sorting records inside group/set help needed

Postby BillyBoyo » Fri Jun 10, 2016 2:58 am

Does that define the start of the set/group? You don't make clear in the description what all the records mean.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: sorting records inside group/set help needed

Postby akanchu » Fri Jun 10, 2016 5:11 am

I am just started the group when it is the first record for that set. By checking 01 in the 15th position.

Some records are person info which is the 010 (17th position) record, could have multiple of these.
Some are misc expenses identified by 310 (17th position), etc. So there could be multiple of these too.

Thanks
AK.
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: sorting records inside group/set help needed

Postby BillyBoyo » Fri Jun 10, 2016 10:42 am

Can you show: expected output; current control cards; result of control cards.

What are those first four records?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: sorting records inside group/set help needed

Postby akanchu » Fri Jun 10, 2016 6:51 pm

Expected output is in my first post.

With the suggestion and some cleanup, the sysin looks like

//SYSIN    DD  *                                                      
   INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,110Z,5)),                      
         IFTHEN=(WHEN=INIT,                                          
                 OVERLAY=(5:115,10,15:SEQNUM,8,ZD,23:87Z)),          
     IFTHEN=(WHEN=GROUP,                              
         BEGIN=(129,2,ZD,EQ,01,OR,131,2,ZD,EQ,00),
         PUSH=(15:ID=8)),                        
         IFTHEN=(WHEN=(131,3,ZD,EQ,010,AND,146,2,ZD,EQ,02),
                 OVERLAY=(23:161,60,221,3))
   SORT FIELDS=(15,8,CH,A,                                            
                23,60,CH,A,    
                25,3,ZD,D)
   OUTREC BUILD=(1,4,111)  
/
 


and the output I am getting is :


----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2
          000000000000000000000ANN
          00000000300000100000001N
          00000000300000200000002N
          00000000400000100000001N
          00000000400000200000002N
BEER11440000000101000000100000003YPP          Chicken                  J        
BEER11440000000201000000200000007YPNBRUCE D JENNER                            
BEER11440000000301000000300000001NPP          Chicken                  J        
BEER11440000000601000000600000012NPNEstate of Chicken J Perdue                    
BEER11440000000701000000700000014NPP          Chicken                  J        
BEER114400000008015000001000000522738130                         0100  NNNNNNNN0
BEER114400000009015000002000000475848840                         0100  NNNNNNNN0
BEER114400000010020000001000000522738130                         1200203000000{0
BEER11440000001131000000100000002D20150528000000000015692{000000000000000{      
BEER11440000001231000000200000002D20150628000000000015692{000000000000000{      
BEER1144000000134000000010000009920150609201606080000000020150609208206
BEER11440000000501000000500000002NPP          Alexis                   E              JENNER              070        
BEER11440000000401000000400000002NPP          Alice                    J              JENNER              030
NEAT26691000000101000000100000003YPP          Andrew                                  Bourdean                    
NEAT26691000000201000000200000007YPP          MARK                                    Bourdean
NEAT26691000000301000000300000001NPP          Andrew                                  Bourdean                    
NEAT26691000000401000000400000001NPP          Christianne              
NEAT26691000000501000000500000012NPNBourdean Kids Irrev Trust                        
NEAT26691000000701000000700000014NPP          Alan and Christianne                    Bourdean
NEAT266910000008015000001000000293606780                         0100  
NEAT266910000009015000002000000570258837                         0100  
NEAT266910000010020000001000000293606780                         120020
NEAT266910000011020000002000000565532184                         120020
NEAT26691000000601000000600000002NPP          Christianne                             Bourdean            100
          000000999000000000000000000000030
 


The initial records are header and lookup records with data.

Thanks
AK.
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post