View previous topic :: View next topic
|
Author |
Message |
srikar tenali
New User
Joined: 07 Feb 2007 Posts: 22 Location: hyderabad
|
|
|
|
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 |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Even easier, look up the ALTSEQ Control Statement..... |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|