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

sorting on other than ascending/descending order


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

New User


Joined: 07 Feb 2007
Posts: 22
Location: hyderabad

PostPosted: Thu Aug 30, 2007 10:58 am
Reply with quote

can we sort on the basis of an user defined order which is other than ascending or descending order.

for eg:

100A100
100B100
100C100

fourth position to be sorted in the order B, A, C.
so the o/p will be like

100B100
100A100
100C100
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Thu Aug 30, 2007 11:04 am
Reply with quote

Code:
// EXEC PGM=SORT                                         
//SORTIN DD *                                           
100A100                                                 
100B100                                                 
100C100                                                 
/*                                                       
//SORTOUT DD SYSOUT=*                                   
//SYSOUT DD SYSOUT=*                                     
//SYSIN DD *                                             
 INREC IFTHEN=(WHEN=(4,1,CH,EQ,C'B'),OVERLAY=(81:C'1')),
       IFTHEN=(WHEN=(4,1,CH,EQ,C'A'),OVERLAY=(81:C'2')),
       IFTHEN=(WHEN=(4,1,CH,EQ,C'C'),OVERLAY=(81:C'3')) 
 SORT FIELDS=(81,1,ZD,A)                                 
 OUTREC FIELDS=(1,80)                                   
/*                                                       
//                                                       

Output:
Code:
100B100
100A100
100C100
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Aug 30, 2007 5:16 pm
Reply with quote

Even easier, look up the ALTSEQ Control Statement.....
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: Fri Aug 31, 2007 4:31 am
Reply with quote

srikar,

Here's a DFSORT job that switches the collating positions of 'A' and 'B':

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
100A100
100B100
100C100
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
   ALTSEQ CODE=(C2C1,C1C2)
   SORT FIELDS=(1,7,AQ,A)
/*
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 Rotate partition-logical & physic... DB2 0
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts DB2 Load - Sort Or order BY DB2 1
No new posts Sorting a record spanned over multipl... DFSORT/ICETOOL 13
Search our Forums:

Back to Top