MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort in a specified sequence of values of one field

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Pranabesh
Beginner


Joined: 22 Sep 2005
Posts: 11
Topics: 5
Location: WI,US

PostPosted: Wed Feb 14, 2007 2:40 am    Post subject: Sort in a specified sequence of values of one field Reply with quote

Hello,

I am just wondering if the below requirement can be done through Syncsort (I have SYNCSORT FOR Z/OS 1.2.2.3N in my shop).

Input file - LRECL - 150, RECFM - FB
Code:

Field      Pos       Data Type   
-----   ---      ----------
Acct No    1-8       Char ( 8 )
Activity   9-12       Char ( 4 )
Date   23-30(YYYYMMDD)    Char ( 8 )

Sort criteria :

The Acct No and Date would be ascending order.
Also, the file should be sorted in such a way that for every unique combination of Acct No and Date, the Activity should appear in the below mentioned order.
On a single day, any one or more than one of the Activity may appear for one Acct No in th e input file. There are several other Activity codes, which should appear in ascending order.
Code:
 
Activity Sequence in output
--------------------------------
 0100
 3018
 3052
 3061
 3060
 3051
 3062

Example :

Input
Code:

-----
Pos 1-8      Pos 9-12      Pos 23-30
-------      --------      ---------
18856735      3062         20070127
18856735      3051         20070127
18856735      3060         20070127
17734567      3018         20070128
17734567      0100         20070128
19923218      3061         20070129
19923218      3052         20070129
19923218      3060         20070129

Output
Code:

-------
Pos 1-8      Pos 9-12      Pos 23-30
-------      --------      ---------
18856735      3060         20070127
18856735      3051         20070127
18856735      3062         20070127
17734567      0100         20070128
17734567      3018         20070128
19923218      3052         20070129
19923218      3061         20070129
19923218      3060         20070129

Could you please let me know how this can be done through Syncsort,
Thanks!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Wed Feb 14, 2007 6:24 am    Post subject: Reply with quote

Quote:

The Acct No and Date would be ascending order.



Pranabesh,

Your Output does NOT match the specs. If you want ascending acctno and date seq the acct no 17734567 will be the first record instead of 18856735. Do you want the output to be sorted first on date and then on the Acct no?

Any way try these untested sort control cards which will give you the results. For all the possible activity sequence assign a variable at the end(151) and sort on it along with acctno and date to get the records in the sequence. While writing out to the output we remove the assigned sequence

Code:

//SYSIN    DD *                             
  SORT FIELDS=(001,08,CH,A,   $ ACCT-NO     
               023,08,CH,A,   $ DATE         
               151,05,CH,A)   $ SEQUENCE     
                                             
  INREC IFTHEN=(WHEN=(09,04,CH,EQ,C'0100'), 
       OVERLAY=(151:C'00001')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3018'), 
       OVERLAY=(151:C'00002')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3052'), 
       OVERLAY=(151:C'00003')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3060'), 
       OVERLAY=(151:C'00004')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3051'), 
       OVERLAY=(151:C'00005')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3062'), 
       OVERLAY=(151:C'00006'))               
                                             
  OUTREC FIELDS=(001,150)                   
/*                                           

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Pranabesh
Beginner


Joined: 22 Sep 2005
Posts: 11
Topics: 5
Location: WI,US

PostPosted: Wed Feb 14, 2007 7:56 pm    Post subject: Reply with quote

Sorry Kolusu, while writing the output example I mentioned the wrong order by mistake. You are right, and the solution worked great!!
Thanks a lot, Kolusu!
Back to top
View user's profile Send private message
Pranabesh
Beginner


Joined: 22 Sep 2005
Posts: 11
Topics: 5
Location: WI,US

PostPosted: Thu Feb 15, 2007 9:45 pm    Post subject: Reply with quote

Hi Kolusu,

One more question. There are several other Activity types e.g. 1439, 6500,0017, 5001.
Can you please let me know how the sort card be changed so that all other Activity types would come after the Activity types I have provided initially, i.e. without overlaying with unique characters for each of the other Activity types,

Thanks!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Thu Feb 15, 2007 10:35 pm    Post subject: Reply with quote

Just assign a higher value for all the other activities . Check for when=none

try these control cards

Code:

//SYSIN    DD *                             
  SORT FIELDS=(001,08,CH,A,   $ ACCT-NO     
               023,08,CH,A,   $ DATE         
               151,05,CH,A)   $ SEQUENCE     
                                             
  INREC IFTHEN=(WHEN=(09,04,CH,EQ,C'0100'), 
       OVERLAY=(151:C'00001')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3018'), 
       OVERLAY=(151:C'00002')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3052'), 
       OVERLAY=(151:C'00003')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3060'), 
       OVERLAY=(151:C'00004')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3051'), 
       OVERLAY=(151:C'00005')),             
        IFTHEN=(WHEN=(09,04,CH,EQ,C'3062'), 
       OVERLAY=(151:C'00006')),               
        IFTHEN=(WHEN=NONE, 
       OVERLAY=(151:C'10000'))
                                         
  OUTREC FIELDS=(001,150)                   
/*   


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Pranabesh
Beginner


Joined: 22 Sep 2005
Posts: 11
Topics: 5
Location: WI,US

PostPosted: Fri Feb 16, 2007 2:05 pm    Post subject: Reply with quote

Yes, it worked. Thanks Kolusu!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group