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 

Applying same sequence number on sets of records.

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


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Sat Mar 26, 2011 3:56 am    Post subject: Applying same sequence number on sets of records. Reply with quote

Hi, I would like to know how to apply same sequence number on duplicate sets of records.

Input:- LRECL=80, RECFM=FB
Code:

----+----1----+----2----+----3----+----4
SET1  0123  ABYZ    0003
RECORD1
RECORD2
RECORD3
SET2  0196  AB1T    0002
RECORD1
RECORD2
SET1  0123  ABYZ    0003
RECORD1
RECORD2
RECORD3
SET1  0124  ABYZ    0003
RECORD1
RECORD2
RECORD3
SET3  0348  AZ1K    0002
RECORD1
RECORD2


The values appearing in 1st, 7th, 13th and 21st (count of detail records) are the keys to be compared between sets of records. The 1st and 3rd sets are same hence should contain same sequence number and other sets with different sequence numbers at 30th column.

Output:
Code:

----+----1----+----2----+----3----+----4
SET1  0123  ABYZ    0003     001
RECORD1                      001
RECORD2                      001
RECORD3                      001
SET2  0196  AB1T    0002     002
RECORD1                      002
RECORD2                      002
SET1  0123  ABYZ    0003     002
RECORD1                      001
RECORD2                      001
RECORD3                      001
SET1  0124  ABYZ    0003     003
RECORD1                      003
RECORD2                      003
RECORD3                      003
SET3  0348  AZ1K    0002     004
RECORD1                      004
RECORD2                      004


Please help.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Mar 27, 2011 1:14 pm    Post subject: Reply with quote

mf_user,


Do you really need the order of records in the same order as input? If the order is not important then the following DFSORT JCL will give you the results. The result set is based on the key (1,24) on the 'set' record which acts like a header for the group.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
SET1  0123  ABYZ    0003                                             
RECORD1                                                               
RECORD2                                                               
RECORD3                                                               
SET2  0196  AB1T    0002                                             
RECORD1                                                               
RECORD2                                                               
SET1  0123  ABYZ    0003                                             
RECORD1                                                               
RECORD2                                                               
RECORD3                                                               
SET1  0124  ABYZ    0003                                             
RECORD1                                                               
RECORD2                                                               
RECORD3                                                               
SET3  0348  AZ1K    0002                                             
RECORD1                                                               
RECORD2                                                               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'SET'),PUSH=(81:1,24))   
  SORT FIELDS=(81,24,CH,A),EQUALS                                     
                                                                     
  OUTREC IFOUTLEN=80,                                                 
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(81,24),PUSH=(30:ID=3))                 
//*


The output from this job is

Code:

SET1  0123  ABYZ    0003     001
RECORD1                      001
RECORD2                      001
RECORD3                      001
SET1  0123  ABYZ    0003     001
RECORD1                      001
RECORD2                      001
RECORD3                      001
SET1  0124  ABYZ    0003     002
RECORD1                      002
RECORD2                      002
RECORD3                      002
SET2  0196  AB1T    0002     003
RECORD1                      003
RECORD2                      003
SET3  0348  AZ1K    0002     004
RECORD1                      004
RECORD2                      004

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


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Mon Mar 28, 2011 12:15 am    Post subject: Reply with quote

Hi, Thanks for the solution you've provided. Yes, I need to get the output as it appears in the order. Can you please let me know how to achieve it? Rolling Eyes
Thanks a lot.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Mar 28, 2011 12:27 pm    Post subject: Reply with quote

mf_user,

I can't think of a way to get the output as you desired. You want the order of the records as is and no break in the group number which is not easy to achieve via SORT. It would require more than 3 passes of data which is think is a mere waste of resources.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Tue Mar 29, 2011 6:42 am    Post subject: my bad luck Reply with quote

Ok Kolusu.....my bad luck Sad
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Thu Mar 31, 2011 3:01 pm    Post subject: Reply with quote

Have u tried adding a sequence # to the INREC to preserve the original sort order of the file? Maybe something like

Code:

INREC IFTHEN=(WHEN=INIT,OVERLAY=(nn:SEQNUM,8.PD)),
          IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'SET'),PUSH=(81:1,24))
...


Then, once you have the desired value in col. 30, you can resort using the original SEQNUM.

HTH...
_________________
Not an expert, but I did stay at a Holiday Inn... though it has been a while...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Mar 31, 2011 3:09 pm    Post subject: Reply with quote

mickeygoo,


Did you notice that there are 2 sets of SET1 0123 ABYZ 0003 records? And both of them have need to have the same group number? By using INREC you will have a break in group numbering.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Thu Mar 31, 2011 3:20 pm    Post subject: Reply with quote

kolusu wrote:
mickeygoo,


Did you notice that there are 2 sets of SET1 0123 ABYZ 0003 records? And both of them have need to have the same group number? By using INREC you will have a break in group numbering.


Actually, I did, but I don't quite understand your point. I thought of adding the WHEN=INIT to add a non-group / non-key-specific sequence # - like a record # - to the input record, the follow up with the rest of the code you specified, just so that there's something he can re-sort with to get the original sort order. I didn't try and code it all out and test it - I just saw this post while I was searching for something else - and thought I'd throw in my 2c. Maybe it needs a HIT=NEXT as well.

I enjoy these discussions - helps me learn about DFSORT better than just reading someone else's code, or reading thru the manuals. And the things people come up with to try and use the utility, coupled with your and Frank's and everyone else's out-of-the box suggestions - it's mind-boggling. Very Happy
_________________
Not an expert, but I did stay at a Holiday Inn... though it has been a while...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Mar 31, 2011 3:38 pm    Post subject: Reply with quote

mickeygoo,

with
Code:

//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                   
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'SET'),PUSH=(30:ID=3,89:1,24))   
//*


the data looks like this
Code:

SET1  0123  ABYZ    0003     001
RECORD1                      001
RECORD2                      001
RECORD3                      001
SET2  0196  AB1T    0002     002
RECORD1                      002
RECORD2                      002
SET1  0123  ABYZ    0003     003
RECORD1                      003
RECORD2                      003
RECORD3                      003
SET1  0124  ABYZ    0003     004
RECORD1                      004
RECORD2                      004
RECORD3                      004
SET3  0348  AZ1K    0002     005
RECORD1                      005
RECORD2                      005


Take a look at group 1 and 3. The are duplicate groups , so both of them should have the same group number 1 which is quite easy to do. However you will skip a group number ( 3 in this case) and your group number will be 1,2,4,5. so whenever there is a duplicate group, there will be a skip and if there are more duplicate groups then you will notice huge spikes in the group numbers.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Mon Apr 04, 2011 7:38 am    Post subject: Reply with quote

Confused I am still optimistic that something would turn up Neutral
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
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