IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sort file on two subsets of data


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Wed Jul 11, 2012 11:15 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 11, 2012 1:31 pm
Reply with quote

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
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Wed Jul 11, 2012 2:10 pm
Reply with quote

Sorry for not posting in the code tag.
yes you are right.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 11, 2012 2:34 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jul 11, 2012 10:22 pm
Reply with quote

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:

Code:

0BBB02       A
0BBB02         
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
Search our Forums:

Back to Top