Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort by custom keys/order

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sort by custom keys/order
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: 1703
Location: Australia

PostPosted: Mon Apr 20, 2009 2:27 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Apr 20, 2009 9:35 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us