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

Sort by custom keys/order


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

New User


Joined: 27 Mar 2009
Posts: 13
Location: London, UK

PostPosted: Mon Apr 20, 2009 2:13 pm
Reply with quote

Hi everyone,
I am stuck as to how I can accomplish the following, does anyone have any ideas please?...

I would like to sort this file by an identifying number, then date, and then by a custom (arbitrary) order of characters. The input file will look like...

123456-01.01.2009-P
123456-01.01.2009-C
123456-05.04.2008-S
111111-09-09-2010-C

(Number is char 1-6, Date is char 8-10, Custom is char 19-1)

which when sorted should in this case reverse the order putting the lowest number first, then by date and the last column instead of being alphabetical I would like to have ordered by 'C' then 'S' then 'P'.

111111-09-09-2010-C
123456-05.04.2008-S
123456-01.01.2009-C
123456-01.01.2009-P

Is this too much to ask or do you think it might be possible please?

Thankyou for your help
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Apr 20, 2009 2:27 pm
Reply with quote

Hi,

assuming the date format is DD-MM-YYYY then try this

Code:
    SORT FIELDS=(1,6,CH,A,14,4,CH,A,11,2,CH,A,8,2,CH,A,19,1,CH,A)



Gerry
Back to top
View user's profile Send private message
Richard J

New User


Joined: 27 Mar 2009
Posts: 13
Location: London, UK

PostPosted: Mon Apr 20, 2009 3:28 pm
Reply with quote

Thankyou for the very quick reply gcicchet, I'm slightly embarassed I didn't think of that for the date. Though it still leaves me with the final character problem as the order I need is not alphabetical (C then S then P). I'm thinking of replacing the characters preceding space with numbers and sorting by that, which may be the simplest solution.

Something along the lines of...

Code:
INREC FINDREP=(INOUT=(C' C ','1C ', C' S ',C'2S ', C' P ',C'3P '))

and including your suggested code but shifting the last sort character to sort the now added preceding number.
Code:
SORT FIELDS=(1,6,CH,A,14,4,CH,A,11,2,CH,A,8,2,CH,A,18,1,CH,A)


Thankyou for your help.
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Mon Apr 20, 2009 7:22 pm
Reply with quote

If the C, S, and P only apear in that field, you can use ALTSEQ to change to sort order of characters C, S and P.

Code:
* Sort C as 0, S as 1 and P as 2
 ALTSEQ CODE=(C3F0,E2F1,D7F2)
 OPTION CHALT                                                   
 SORT FIELD=(18,1,CH,A)
Of course, add the other sort fields to the card, too.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Apr 20, 2009 9:35 pm
Reply with quote

Richard,

I'd suggest these DFSORT control statements:

Code:

  ALTSEQ CODE=(C3F0,E2F1,D7F2)
  SORT FIELDS=(1,6,CH,A,
    14,4,CH,A,11,2,CH,A,8,2,CH,A,
    19,1,AQ,A)


CHALT would cause all of the CH fields to sort with the ALTSEQ changes. Since you only want position 19 to sort with the ALTSEQ changes, it's better to use AQ to sort just that field with the ALTSEQ changes.
Back to top
View user's profile Send private message
Richard J

New User


Joined: 27 Mar 2009
Posts: 13
Location: London, UK

PostPosted: Mon Apr 20, 2009 9:48 pm
Reply with quote

FANTASTIC!
Thanks for all your help Biill and Frank, your ALTSEQ has done exactly what I needed.

Cheers
Rich
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Rotate partition-logical & physic... DB2 0
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top