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 

Help needed in sorting.

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


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Wed Sep 21, 2005 11:55 pm    Post subject: Help needed in sorting. Reply with quote

Hi Team

I have got a problem in sorting.
My Input record looks something like this
Code:

1234ABCD 20040920 C 20050921 000
1234ABCD 20040920 A 20050921 000
1234ABCD 20040920 I 20050921 000
1234ABCD 20040920 R 20050921 000
1234ABCD 20040920 R 20050922 000
1234ABCD 20040920 A 20050921 000

5678UVWX 20040712 R 20050921 000
5678UVWX 20040712 R 20050921 000
5678UVWX 20040712 A 20050921 000

My desired Output is as follows
Code:

1234ABCD 20040920 I 20050921 001
1234ABCD 20040920 A 20050921 002
1234ABCD 20040920 A 20050921 003
1234ABCD 20040920 R 20050921 004
1234ABCD 20040920 C 20050921 005
1234ABCD 20040920 R 20050922 001

5678UVWX 20040712 A 20050921 001
5678UVWX 20040712 R 20050921 002
5678UVWX 20040712 R 20050921 003

The first 8 bytes is the number followed by a filler and then 8 bytes of registration date adn then a filler. Then it is the type of number with a filler and then followed by the entry date and a filler.
The last 3 bytes are the sequence number.
The requirement is for each number and registration date if the entry date changes then the sequence number starts again from one. else if it is the same number, entry date and registration date then depending on the type of number the sequence number needs to be increased. (If I is present it always takes first position, followed by A the R and the C).

Could this be done using sort.

Thanks in advance.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 22, 2005 12:09 am    Post subject: Reply with quote

gauthaman_mech,

This is a bit too tricky to do with Sort. First of all, I need to know what Sort product (DFSORT / Syncsort) you are using and also the version of Sort you are running on ?

To find out the version of Sort, just write any dummy sort step (use PGM=SORT), go to Sysout and look at the first line. (Better paste the entire line for us).

Thanks,
Phantom
Back to top
View user's profile Send private message
gauthaman_mech
Beginner


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Thu Sep 22, 2005 12:35 am    Post subject: help needed in sorting Reply with quote

The first line in Sysout reads as folows:

SYNCSORT FOR Z/OS 1.1DN TPF3 U.S. PATENTS: 4210961, 5117495

We are using Syncsort in our shop.

Thanks in advance.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 22, 2005 12:51 am    Post subject: Reply with quote

gauthaman_mech,

Check this thread. I had asked the same question some time back. But I had a very old version of syncsort at that time - which did not support SPLICE.
http://www.mvsforums.com/helpboards/viewtopic.php?t=2628&highlight=breaking

You need to tailor the code to your needs. But that should be easy.

Try and let us know if you face any problems.

Thanks,
Phantom
Back to top
View user's profile Send private message
gauthaman_mech
Beginner


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Thu Sep 22, 2005 12:59 am    Post subject: Reply with quote

Phantom
Thanks for the link.
It is fine if I need to break on the key. But here even if I break on the key (entry date) I need to check if the type of number takes its appropriate position, which makes the problem worse.
So what I think would ultimately happen is that for the same entry date the sequence number would be put either in ascending or descending order of the type of number. But the sequnce should be put according to the order as I then A then R and then C.

Thanks in advance.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 22, 2005 1:21 am    Post subject: Reply with quote

gauthaman_mech,

I am not good in SPLICE. My new shop has Syncsort v 1.1 that supports SPLICE but I'm yet to try it to understand the flow.

Try to see if you can pre-sort the records in the order of Type field and then apply SPLICE.

I bet Kolusu can easily answer your question. I will try and see if I can do something for you.

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


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

PostPosted: Thu Sep 22, 2005 7:26 am    Post subject: Reply with quote

gauthaman_mech,

The following DFSORT/ICETOOL JCL will give you the desired results.If your shop has syncsort then change the pgm name to synctool.

Code:

//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                     
1234ABCD 20040920 C 20050921 000                                   
1234ABCD 20040920 A 20050921 000                                   
1234ABCD 20040920 I 20050921 000                                   
1234ABCD 20040920 R 20050921 000                                   
1234ABCD 20040920 R 20050922 000                                   
1234ABCD 20040920 A 20050921 000                                   
5678UVWX 20040712 R 20050921 000                                   
5678UVWX 20040712 R 20050921 000                                   
5678UVWX 20040712 A 20050921 000
//T1       DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                         
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2                         
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SORT FROM(IN) USING(CTL1)                                         
  SPLICE FROM(CON) TO(OUT) -                                       
           ON(34,24,CH)    -                                       
           WITH(1,61)      -                                       
           WITHALL  USING(CTL2)
//CTL1CNTL DD *                                         
  INREC FIELDS=(01,33,                                 
                01,08,                                 
                10,08,                                 
                21,08,                                 
                58:19,1,CHANGE=(1,C'I',C'1',           
                                  C'A',C'2',           
                                  C'R',C'3',           
                                  C'C',C'4'),           
                                NOMATCH=(C'5'))         
  SORT FIELDS=(34,25,CH,A)                             
  OUTREC FIELDS=(1,58,SEQNUM,3,ZD,3X)                   
  OUTFIL FNAMES=T1,                                     
         SECTIONS=(34,24,                               
         TRAILER3=(1,61,MIN=(59,3,ZD,M11,LENGTH=3))),   
         NODETAIL,                                     
         REMOVECC                                       
  OUTFIL FNAMES=T2                                     
//CTL2CNTL DD *                                         
  OUTFIL FNAMES=OUT,                                   
         OUTREC=(1,29,                                 
         ((59,3,ZD,SUB,62,3,ZD),ADD,+1),EDIT=(TTT))
/*                                                     


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
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 22, 2005 8:00 am    Post subject: Reply with quote

Kolusu,

Thanks a lot for the solution. I need to learn how to use SPLICE. I have seen many posts, but never tried to work on that till date....Need to update myself soon.

Gauthaman_mech,

The great Kolusu has proved himself once again.
Quote:

I bet Kolusu can easily answer your question


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


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

PostPosted: Thu Sep 22, 2005 8:08 am    Post subject: Reply with quote

Phantom,

Splice can be a bit confusing , but once you get a hang of it, then it is very easy. !

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


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Thu Sep 22, 2005 11:22 am    Post subject: Reply with quote

Kolusu, Phantom
Thanks a lot for all the help given. It worked.

Just had one more doubt if I add some data (basically some amounts) in the input file after the sequence number then i loose the control. Could you please tell me where I am going wrong.

My JCL is as follows:
Code:

//STEP0100 EXEC PGM=SYNCTOOL                                         
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD *                                                     
1234ABCD 20040920 C 20050921 000 2000                               
1234ABCD 20040920 A 20050921 000 1000                               
1234ABCD 20040920 I 20050921 000 5000                               
1234ABCD 20040920 R 20050921 000 6000                               
1234ABCD 20040920 R 20050922 000 5000                               
1234ABCD 20040920 A 20050921 000 7000                               
5678UVWX 20040712 R 20050921 000 5000                               
5678UVWX 20040712 R 20050921 000 0500                               
5678UVWX 20040712 A 20050921 000 0100                               
/*                                                                   
//T1       DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=&T1,DISP=(OLD,DELETE),VOL=REF=*.T1                 
//         DD DSN=&T2,DISP=(OLD,DELETE),VOL=REF=*.T2                 
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                     
  SORT FROM(IN) USING(CTL1)                                         
  SPLICE FROM(CON) TO(OUT) -                                         
           ON(34,24,CH)    -                                         
           WITH(1,70)      -                                         
           WITHALL USING(CTL2)                                       
//CTL1CNTL DD *                                                     
    INREC FIELDS=(01,38,                                             
                  01,08,                                             
                  10,08,                                             
                  21,08,                                             
                  34,04,                                             
                  67:19,1,CHANGE=(1,C'I',C'1',                       
                                    C'A',C'2',                       
                                    C'R',C'3',                       
                                    C'C',C'4'),                         
                                  NOMATCH=(C'5'))                       
  SORT FIELDS=(39,24,CH,A,67,1,CH,A)                                   
  OUTREC FIELDS=(1,67,SEQNUM,3,ZD,3X)                                   
  OUTFIL FNAMES=T1,                                                     
         SECTIONS=(39,24,                                               
         TRAILER3=(1,70,MIN=(68,3,ZD,M11,LENGTH=3))),                   
         NODETAIL,                                                     
         REMOVECC                                                       
  OUTFIL FNAMES=T2                                                     
//CTL2CNTL DD *                                                         
  OUTFIL FNAMES=OUT,                                                   
         OUTREC=(1,29,                                                 
         ((68,3,ZD,SUB,71,3,ZD),ADD,+1),EDIT=(TTT),34,4)               
/*                         



My output that I get is
Code:

5678UVWX 20040712 R 20050921 0030500         
1234ABCD 20040920 C 20050921 0052000         
1234ABCD 20040920 I 20050921 0045000         
1234ABCD 20040920 R 20050922 0015000         

The desired output should be the same as given before.

Could you tell me where I am going wrong.

Thanks in advance.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Sep 22, 2005 11:47 am    Post subject: Reply with quote

gauthaman_mech,

You forgot to change the SPLICE card in the toolin.

it should be

Quote:

SPLICE FROM(CON) TO(OUT) -
ON(39,24,CH) -
WITH(1,70) -
WITHALL USING(CTL2)


Also you did account for the filler after seqnum in your final output.

So change your ctl2 to the following.

Quote:

//CTL2CNTL DD *
OUTFIL FNAMES=OUT,
OUTREC=(1,29,
((68,3,ZD,SUB,71,3,ZD),ADD,+1),EDIT=(TTT),33,5)
/*


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
gauthaman_mech
Beginner


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Thu Sep 22, 2005 9:17 pm    Post subject: help needed in sorting Reply with quote

Kolusu
Thanks a lot, it works the way it is needed.
Thanks for all the help and guidance provided by you and Phantom.
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