View previous topic :: View next topic
|
Author |
Message |
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi All,
This is my requirement,
I have an input file with the RCL of 516. i have to sort only the records which has 02,03 in the 20th position,(sorting should be done based on 20 & 516th position.) excluding the other records and sorting should be done such as 02 in descending and 03 in ascending. but the final output should be sorted based on 20th & 516 field, i.e) 01,02....11(20th position). Records will be in bunch as illustarted below i.e) 0AAA01 to 0QWE11 and again 0AAA01 to 0QWE11 the same.
Code: |
20 516
0AAA01
0BBB02
0BBB02 A
0CCC03 A
0CCC03
0CCC03
0DDD04
...
...
0QWE11
0AAA01
0BBB02
0BBB02 A
0CCC03 A
0CCC03
0CCC03
0DDD04
...
...
0QWE11 |
i need the o/p as follows
Code: |
20 516
0AAA01
0BBB02 A
0BBB02
0CCC03
0CCC03
0CCC03 A
0DDD04
...
...
0QWE11
0AAA01
0BBB02 A
0BBB02
0CCC03
0CCC03
0CCC03 A
0DDD04
...
...
0QWE11 |
Code'd and alignment of two A's guessed-at. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You'd been here long enough to use the Code tags for posting.
You are saying you have two subsets of data in your file; they need to be sorted "in place", ie all the records in their new position will be in locations previously occupied by records of the same type in the same "group", the group only being defined by a number of consecutive records of that type; groups for one record type are to be sorted ascending, the other descending.
Is that about it?
Yes, it can be done if you confirm/explain. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Sorry for not posting in the code tag.
yes you are right. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You will need to create a new field for the sort key on your records.
For records that you want to stay the same, this needs to contain a record sequence-number.
Define a group for your required records. Use the record sequence-number of the group header for the first key, so all records in the group will have the same "sequence number".
Then you need a new field for your subset key. The ascending is easy. There are a number of ways to deal with the descending. Perhaps because your key is so short, just "invert". Define a field for the desceding key as binary, and subtract it from zero to give you the descending key for an ascending sort.
Sort on the two new keys.
Use OUTREC/OUTFIL BUILD to strip off the extra filekds. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
anandinmainframe,
How did a space record get sorted after 'A' ? If you are sorting on ASCENDING sequence , the space record will be the first record when sorted.
ex:
|
|
Back to top |
|
|
|