View previous topic :: View next topic
|
Author |
Message |
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
We have a field with Length "22" which is a character field and it can have digits upto 22 as shown in the example below.
Code: |
22222222222222bbbbbbbb
1222222222222222bbbbbb
|
where "b" denotes SPACE.
I want to sort this data on Ascending order and using below card.
Code: |
SORT FIELDS=(1,22,CH,A)
|
I am expecting output as below
Code: |
22222222222222bbbbbbbb
1222222222222222bbbbbb
|
But I am getting output as below which is not correct. It seems, first digit is less for "1222222222222222bbbbbb", so showing "1222222222222222bbbbbb" first and the other next.
Code: |
1222222222222222bbbbbb
22222222222222bbbbbbbb
|
Can somebody help?
Regards,
KSK |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
during the input phase, build (add) an extra field to the record,
where you have right justified the data from the 22 char field,
and sort on the new field.
during output phase, remove the extra field. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Ksk,
if the input is numbers as you show , you can use UFF format for sorting.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1222222222222222
22222222222222
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,22,UFF,A)
//* |
The output from this is
Code: |
22222222222222
1222222222222222
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
UFF saves the day. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Thanks for the prompt replies.
Both solutions are working good but the 2nd one requires less efforts. |
|
Back to top |
|
|
|