Need some help to sort with a group



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

Need some help to sort with a group

Postby akanchu » Tue May 06, 2014 2:40 am

I have the below file where in 1 thru 10 bytes are values of 1 set .
Was trying to sort the data based on position 49 onwards for 50 bytes.
015258642   01EXXQ01AL7859689FI      DEM   050H09348341L11 FINANCIAL  TLC                       
015258642   01EXXQ01AL7859689FI      PBS
015258642   01EXXQ01AL7859689FI      FA1
015258642   01EXXQ01AL7859689FI      BEN
015258643   01EXXQ01AL7859689FI      DEM   040H09348342P1L FINANCIAL  DDC                       
015258643   01EXXQ01AL7859689FI      PBS
015258643   01EXXQ01AL7859689FI      FA1
015258643   01EXXQ01AL7859689FI      BEN
016279862   01NYYW05HI7859688ID      DEM   020H07688688USA REPRESENTATIVE CORP 
016279862   01NYYW05HI7859688ID      PBS
016279862   01NYYW05HI7859688ID      FA1
016279862   01NYYW05HI7859688ID      BEN
016279997   01NYYW05GA7859687ID      DEM   120H07349349BUMBLE BEE INC             
016279997   01NYYW05GA7859687ID      PBS
016279997   01NYYW05GA7859687ID      FA1
016279997   01NYYW05GA7859687ID      BEN


Tried the following :
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(38,3,CH,EQ,C'DEM'),PUSH=(10123:ID=4)),
        IFTHEN=(WHEN=INIT,OVERLAY=(10001:5516,12,1983,100,1,10))         
  SORT FIELDS=(10001,126,CH,A),EQUALS                                   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(38,3,CH,EQ,C'DEM'),                   
                 PUSH=(10127:ID=4)),                                     
        IFTHEN=(WHEN=INIT,OVERLAY=(10001:5516,12,1983,100,1,10))         


But when I do that, the rest of the records get shuffled into different positions.
Tried group and seq, did not get it the way I want.

Expected output :
016279862   01NYYW05HI7859688ID      DEM   020H07688688USA REPRESENTATIVE CORP 
016279862   01NYYW05HI7859688ID      PBS
016279862   01NYYW05HI7859688ID      FA1
016279862   01NYYW05HI7859688ID      BEN
015258643   01EXXQ01AL7859689FI      DEM   040H09348342P1L FINANCIAL  DDC                       
015258643   01EXXQ01AL7859689FI      PBS
015258643   01EXXQ01AL7859689FI      FA1
015258643   01EXXQ01AL7859689FI      BEN
015258642   01EXXQ01AL7859689FI      DEM   050H09348341L11 FINANCIAL  TLC                       
015258642   01EXXQ01AL7859689FI      PBS
015258642   01EXXQ01AL7859689FI      FA1
015258642   01EXXQ01AL7859689FI      BEN
016279997   01NYYW05GA7859687ID      DEM   120H07349349BUMBLE BEE INC             
016279997   01NYYW05GA7859687ID      PBS
016279997   01NYYW05GA7859687ID      FA1
016279997   01NYYW05GA7859687ID      BEN


Please guide me how can I rearrange it.
Thanks
Aka
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Need some help to sort with a group

Postby BillyBoyo » Tue May 06, 2014 4:05 am

Ok, you sa 49 for 50 bytes, but that does not appear in your code.

If you make the ID from the GROUP the major part of the sort key, you will get all items for a group staying together. Is that what you want?

Otherwise, please clarify, and show the output your actually get, as well as the expected output.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need some help to sort with a group

Postby akanchu » Tue May 06, 2014 7:14 am

Thanks for replying, I had adjusted the data to fit the screen.. forgot to adjust the parms.

  INREC IFTHEN=(WHEN=GROUP,BEGIN=(38,3,CH,EQ,C'DEM'),PUSH=(123:ID=4)),
        IFTHEN=(WHEN=INIT,OVERLAY=(101:44,12,56,30,1,10))         
  SORT FIELDS=(101,52,CH,A),EQUALS                                   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(38,3,CH,EQ,C'DEM'),                   
                 PUSH=(127:ID=4)),                                     
        IFTHEN=(WHEN=INIT,OVERLAY=(101:44,12,56,30,1,10))


Output looked like, the DEM records went down.. and the records with spaces remained up.
015258642   01EXXQ01AL7859689FI      PBS
015258642   01EXXQ01AL7859689FI      FA1
015258642   01EXXQ01AL7859689FI      BEN
015258643   01EXXQ01AL7859689FI      PBS
015258643   01EXXQ01AL7859689FI      FA1
015258643   01EXXQ01AL7859689FI      BEN
016279862   01NYYW05HI7859688ID      PBS
016279862   01NYYW05HI7859688ID      FA1
016279862   01NYYW05HI7859688ID      BEN
016279997   01NYYW05GA7859687ID      PBS
016279997   01NYYW05GA7859687ID      FA1
016279997   01NYYW05GA7859687ID      BEN
016279862   01NYYW05HI7859688ID      DEM   020H07688688USA REPRESENTATIVE CORP 
015258643   01EXXQ01AL7859689FI      DEM   040H09348342P1L FINANCIAL  DDC                       
015258642   01EXXQ01AL7859689FI      DEM   050H09348341L11 FINANCIAL  TLC                       
016279997   01NYYW05GA7859687ID      DEM   120H07349349BUMBLE BEE INC             
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Need some help to sort with a group

Postby BillyBoyo » Tue May 06, 2014 12:59 pm

As I said earlier, to keep the groups together, you need the ID you have pushed to be the major part of the sort key. You need to sort on the ID, then on the rest of the data. Or, if you have some other grouping to do, make that the major part, then the ID, then the sequencing within the group.

Perhaps you can describe what sequence you need?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need some help to sort with a group

Postby akanchu » Tue May 06, 2014 6:46 pm

So I added the ID that I am pushing to the sort key, but I get the same result
SORT FIELDS=(101,52,CH,A,123,4,CH,A),EQUALS                                   


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

Re: Need some help to sort with a group

Postby BillyBoyo » Tue May 06, 2014 6:56 pm

"Major" means before the rest of the key. The ID as the minor key is what you did originally, it was just stuck on the end of the data.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need some help to sort with a group

Postby akanchu » Tue May 06, 2014 7:14 pm

I am sorry, but I may not be picking up your hints right or I might not have stated my requirement clearly.
If I move the id before the rest of the key, I think it will just order the records within that group.
My need is to sort it based on the group, based on data in pos 49.
015258642   01EXXQ01AL7859689FI      DEM   050H09348341L11 FINANCIAL  TLC                       
015258642   01EXXQ01AL7859689FI      PBS
015258642   01EXXQ01AL7859689FI      FA1
015258642   01EXXQ01AL7859689FI      BEN
015258643   01EXXQ01AL7859689FI      DEM   040H09348342P1L FINANCIAL  DDC                       
015258643   01EXXQ01AL7859689FI      PBS
015258643   01EXXQ01AL7859689FI      FA1
015258643   01EXXQ01AL7859689FI      BEN
016279862   01NYYW05HI7859688ID      DEM   020H07688688USA REPRESENTATIVE CORP 
016279862   01NYYW05HI7859688ID      PBS
016279862   01NYYW05HI7859688ID      FA1
016279862   01NYYW05HI7859688ID      BEN
016279997   01NYYW05GA7859687ID      DEM   120H07349349BUMBLE BEE INC             
016279997   01NYYW05GA7859687ID      PBS
016279997   01NYYW05GA7859687ID      FA1
016279997   01NYYW05GA7859687ID      BEN


So in this case 016279862 group has 020H0768868 which should come at the top.
016279862   01NYYW05HI7859688ID      DEM   020H07688688USA REPRESENTATIVE CORP 
016279862   01NYYW05HI7859688ID      PBS
016279862   01NYYW05HI7859688ID      FA1
016279862   01NYYW05HI7859688ID      BEN
015258643   01EXXQ01AL7859689FI      DEM   040H09348342P1L FINANCIAL  DDC                       
015258643   01EXXQ01AL7859689FI      PBS
015258643   01EXXQ01AL7859689FI      FA1
015258643   01EXXQ01AL7859689FI      BEN
015258642   01EXXQ01AL7859689FI      DEM   050H09348341L11 FINANCIAL  TLC                       
015258642   01EXXQ01AL7859689FI      PBS
015258642   01EXXQ01AL7859689FI      FA1
015258642   01EXXQ01AL7859689FI      BEN
016279997   01NYYW05GA7859687ID      DEM   120H07349349BUMBLE BEE INC             
016279997   01NYYW05GA7859687ID      PBS
016279997   01NYYW05GA7859687ID      FA1
016279997   01NYYW05GA7859687ID      BEN


Apologies if I was not clear.
Thanks.
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Need some help to sort with a group

Postby akanchu » Tue May 06, 2014 8:28 pm

I have figured out the way to get this done.
Did a push of 49 bytes and the 1 thru 10 bytes when it reads DEM record
The PUSH helped me to replicate the same value found in DEM record onto the other, so they all have the same value
and then did a sort based on the pushed value.

Got it the way I want it.

Thank you for your help.
Aka
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Need some help to sort with a group

Postby BillyBoyo » Tue May 06, 2014 9:39 pm

Thanks for the update. You wanted to sort the entire file on the value from 49 on the DEM record, keeping the groups together? I think what you've said you've down sounds about right.

I don't think you'll need the 1,10 or even the ID. If you have duplicate keys, the EQUALS is going to ensure that records do not become intermingled.

If going that way, ensure that the use of EQUALS is commented to that effect, so someone doesn't "make it more efficient" by removing the EQUALS without thinking about it.

Kudos for getting there yourself.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post