Giving precedence to 1 record among GROUP



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

Giving precedence to 1 record among GROUP

Postby upendra_water » Mon Aug 23, 2010 8:17 am

I have one requirement in my project wherein I need to sort a file and select a particular record depending on some condition.
The file is FB and LRECL is 13. Merchant no is 10 byte and Region ID is 3 byte.
The structure of file to be sorted is as follows:

Merchant No Region
------------ -----------
1111111111 CCC or UUU (Only 1 can exist at a time)
1111111111 GGG
1111111111 FFF
1111111111 UNK

Now the requirement is to maintain only 1 record among these records by giving precedence to region as follows:

FFF > GGG > (CCC/UUU) > UNK

i.e. if a merchant exists in FFF and GGG then I need to retain only FFF.
If it exists in GGG and (CCC or UUU) I need to retain only GGG.
If it exists in all regions I need to retain only FFF.
If it exists in only one region I need to retain that record as is.

So output of above file should be
1111111111 FFF

Is this possible using a sort card in minimum number of steps?
upendra_water
 
Posts: 33
Joined: Wed Nov 25, 2009 10:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Giving precedence to 1 record among GROUP

 

Re: Giving precedence to 1 record among GROUP

Postby Thampy » Tue Aug 24, 2010 4:05 am

Try the following Syncsort JCL

//STEP010   EXEC PGM=SORT                                           
//SYSOUT    DD   SYSOUT=*                                           
//SORTIN    DD *                                                     
1111111111CCC                                                       
1111111111GGG                                                       
1111111111FFF                                                       
2222222222UUU                                                       
2222222222CCC                                                       
3333333333UNK                                                       
3333333333GGG                                                       
3333333333CCC 
4444444444UNK                                                       
//SORTOUT   DD SYSOUT=*                                             
//SYSIN     DD   *                                                   
  INREC IFTHEN=(WHEN=(11,3,CH,EQ,C'FFF'),OVERLAY=(80:C'1')),         
            IFTHEN=(WHEN=(11,3,CH,EQ,C'GGG'),OVERLAY=(80:C'2')),         
            IFTHEN=(WHEN=(11,3,SS,EQ,C'CCC,UUU'),OVERLAY=(80:C'3')),     
            IFTHEN=(WHEN=(11,3,CH,EQ,C'UNK'),OVERLAY=(80:C'4'))         
  SORT FIELDS=(1,10,A,80,1,A),FORMAT=CH                             
  OUTREC OVERLAY=(81:SEQNUM,3,ZD,RESTART=(1,10))                     
  OUTFIL BUILD=(1,13),INCLUDE=(81,3,ZD,EQ,1)                         
/*
"Code'd"

Output
1111111111FFF
2222222222UUU
3333333333GGG
4444444444UNK
Thampy
 
Posts: 35
Joined: Sat Sep 26, 2009 2:27 pm
Has thanked: 0 time
Been thanked: 3 times

Re: Giving precedence to 1 record among GROUP

Postby upendra_water » Tue Aug 24, 2010 10:35 am

Thanks a lot Thampy, it works.
upendra_water
 
Posts: 33
Joined: Wed Nov 25, 2009 10:58 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post