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 

sorting with in a set of records

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


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 1:10 pm    Post subject: sorting with in a set of records Reply with quote

I have a file with below lay out:

rec type - record data
111 xxxxxxxxxxxxxxx
111 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
333 xxxxxxxxxxxxxxx
333 xxxxxxxxxxxxxxx
444 xxxxxxxxxxxxxxx
444 xxxxxxxxxxxxxxx
777 xxxxxxxxxxxxxxx
777 xxxxxxxxxxxxxxx
999 xxxxxxxxxxxxxxx
999 xxxxxxxxxxxxxxx
111 xxxxxxxxxxxxxxx
111 xxxxxxxxxxxxxxx
111 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
222 xxxxxxxxxxxxxxx
333 xxxxxxxxxxxxxxx
333 xxxxxxxxxxxxxxx
444 xxxxxxxxxxxxxxx
444 xxxxxxxxxxxxxxx
444 xxxxxxxxxxxxxxx
777 xxxxxxxxxxxxxxx
777 xxxxxxxxxxxxxxx
999 xxxxxxxxxxxxxxx
999 xxxxxxxxxxxxxxx
999 xxxxxxxxxxxxxxx

I would like to sort records of same type that come together. For example, sort the first two records (same type of 111 and coming together), and then sort three 222 records (same type of 222 and coming together),.....sort 3 records of 111 type, sort 3 records of 222 type, and so on.

sort key is different for different types. And i dont need to sort the record types 999.
_________________
Thanks
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 20, 2007 1:24 pm    Post subject: Reply with quote

Using you input sample, please show what you expect the output to look like....
Back to top
View user's profile Send private message
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 1:40 pm    Post subject: Reply with quote

sorry, the alignment was not proper in previous post. here they are:
Code:

INPUT       |   OUTPUT
RECORDS     |   RECORDS   
111   AAA   |   111   AAA
111   CCC   |   111   BBB
111   BBB   |   111   CCC
222   AAA   |   222   AAA
222   CCC   |   222   BBB
222   BBB   |   222   CCC
333   AAA   |   333   AAA
333   CCC   |   333   BBB
333   DDD   |   333   CCC
333   BBB   |   333   DDD
444   AAA   |   444   AAA
444   DDD   |   444   BBB
444   RRR   |   444   DDD
444   WWW   |   444   RRR
444   BBB   |   444   WWW
111   AAA   |   111   AAA
111   DDD   |   111   BBB
111   BBB   |   111   DDD
222   AAA   |   222   AAA
222   ZZZ   |   222   BBB
222   BBB   |   222   ZZZ
333   AAA   |   333   AAA
333   CCC   |   333   BBB
333   DDD   |   333   CCC
333   BBB   |   333   DDD
444   AAA   |   444   AAA
444   DDD   |   444   BBB
444   ZZZ   |   444   DDD
444   WWW   |   444   WWW
444   BBB   |   444   ZZZ

_________________
Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Sep 20, 2007 3:21 pm    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,
           OVERLAY=(81:SEQNUM,8,ZD,97:SEQNUM,8,ZD,RESTART=(1,3))),
        IFTHEN=(WHEN=(97,8,ZD,EQ,+1),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  SORT FIELDS=(81,8,ZD,A,9,3,CH,A)
  OUTREC BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 4:12 pm    Post subject: Reply with quote

It's workign Frank. But I have some mroe customization required.

sort key is different for different record type.
Eg.: for type 111 - its from 3-8
for type 222 - its from 3-20 etc.

one more is, I would not like to sort some of the records types as I dont need them to sort. Hcen i would like to skip the sorting for the same to save the time. eg: I dont want to sort the records types 333. Is it possible?
_________________
Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Sep 20, 2007 4:46 pm    Post subject: Reply with quote

Yes, it's possible, but if you want me to show you how to do it, you have to give your complete requirements.

Quote:
sort key is different for different record type.


Give the starting position and length of the sort key for every record type regardless of whether you want to sort it or not.

Quote:
one more is, I would not like to sort some of the records types as I dont need them to sort. Hcen i would like to skip the sorting for the same to save the time. eg: I dont want to sort the records types 333. Is it possible?


If you are trying to avoid sorting for some of the record types to "save time", don't bother. Even if you want some of the records in sorted order and others in their original order, you must still sort them all so there's no saving in time involved (it may actually take more time to keep them in their original order). If you want some of the record types in their original order because they need to be in their original order, that's a different story - in that case, you need to give me a complete list of record types for which you want to keep the records in their original order.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 5:45 pm    Post subject: Reply with quote

2nd issue-
Okay, as you suggested, lets leave them sorted.

1st issue-
for records type 111, sort key start position is 10, with a length of 10
for records type 222, sort key start position is 10, with a length of 20
for records type 111, sort key start position is 10, with a length of 15

Please revert if this info is not enough.
_________________
Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Sep 20, 2007 6:09 pm    Post subject: Reply with quote

In your input example, I see record types 111, 222, 333, 444, 111, 222, 333, 444 in that order.

You say type 111 has 10,10, type 222 has 10,20 and type 111 has 10,15. I don't know how to make sense of that. How does that correspond to the two sets of 111, 222, 333 and 444 record types? Are the sort fields for the first and second sets of 111 types different (10,10 and 10,15)? How do you distinguish one 111 type from the other 111 type? Are the sort fields for both sets of 222 types the same (10,20)? What are the sort fields for the first and second sets of 333 and 444 types? Please give complete information.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 6:15 pm    Post subject: Reply with quote

sorry frank, its typo error.
for all records type of 111, sort key start position is 10, with a length of 10
for all records type of 222, sort key start position is 10, with a length of 20
for all records type of 333, sort key start position is 10, with a length of 15
for all records type of 444, sort key start position is 10, with a length of 15
_________________
Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Sep 20, 2007 6:50 pm    Post subject: Reply with quote

Given that all of the sort fields start at the same position, I think you only need to change the SORT statement in my job to the following:

Code:

   SORT FIELDS=(81,8,ZD,A,10,20,CH,A)   


This should work unless you have duplicate keys for the 111, 333 or 444 type records followed by other non-blank characters that have to be kept in their original order.

If it doesn't work, please show me an example of the input records and actual vs expected output for which it doesn't work.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Thu Sep 20, 2007 7:09 pm    Post subject: Reply with quote

Sorry for changing the sort fields. I thougt i could change in code directly. but you generic solution wasn't allowing me to adopt below:

111 - sort fields (20,10), (10,5), and (50,60)
222 - sort fields (20,10), (10,5)
333 - sort fields (20,10), (10,5)
444 - here i dont bother about sorting these records, hence i can say (1,20)
_________________
Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11151
Topics: 71
Location: San Jose

PostPosted: Fri Sep 21, 2007 7:51 am    Post subject: Reply with quote

Sarangadhar,

bonk bonk bonk

kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Fri Sep 21, 2007 11:26 am    Post subject: Reply with quote

Sorry,
Assume some random fields for sort keys, but with different values for different record types, as I am yet to freeze the sort fields. We are working on the sorting keys currently.
_________________
Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Sep 21, 2007 11:38 am    Post subject: Reply with quote

Quote:
Assume some random fields for sort keys, but with different values for different record types, as I am yet to freeze the sort fields. We are working on the sorting keys currently.


You've got to be kidding! Rolling Eyes If I give you a "generic" solution, you'll just come back and tell me you can't figure out how to adapt it to your "real" requirements.

When you figure out your "real" requirements, come back and post them clearly and in detail: Show an example of your input records and expected output records. Give all of the sort field information for all of the record types. Give the RECFM and LRECL of the input file.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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