sorting with in a set of records
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: sorting with in a set of records Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 1:10 pm
    —
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.

#2:  Author: CICS Guy PostPosted: Thu Sep 20, 2007 1:24 pm
    —
Using you input sample, please show what you expect the output to look like....

#3:  Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 1:40 pm
    —
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

#4:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Sep 20, 2007 3:21 pm
    —
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)
/*

#5:  Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 4:12 pm
    —
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?

#6:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Sep 20, 2007 4:46 pm
    —
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.

#7:  Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 5:45 pm
    —
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.

#8:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Sep 20, 2007 6:09 pm
    —
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.

#9:  Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 6:15 pm
    —
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

#10:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Sep 20, 2007 6:50 pm
    —
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.

#11:  Author: SarangadharLocation: virtual village PostPosted: Thu Sep 20, 2007 7:09 pm
    —
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)

#12:  Author: kolusuLocation: San Jose PostPosted: Fri Sep 21, 2007 7:51 am
    —
Sarangadhar,

bonk bonk bonk

kolusu

#13:  Author: SarangadharLocation: virtual village PostPosted: Fri Sep 21, 2007 11:26 am
    —
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.

#14:  Author: Frank YaegerLocation: San Jose PostPosted: Fri Sep 21, 2007 11:38 am
    —
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.



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group