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

Sort Numeric field with spaces


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ismail.hasan

New User


Joined: 28 Mar 2007
Posts: 21
Location: India

PostPosted: Mon Dec 22, 2008 6:50 pm
Reply with quote

Hi
My Input values are like this
1
5
3
203
100
20
1002
2
200
10

After sort using syncsort data type CH length (1,4)

What i am getting is
1
10
100
1002
2
20
200
203
3
5

But I need output file in the below format:

1
2
3
5
10
20
100
200
203
1002

Seeking your guidance.
Thanks is Advance.
Ismail
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Dec 22, 2008 7:27 pm
Reply with quote

Numeric fields need to be justified to get the correct results from a sort process.

Where are these numbers supplied from ?
Back to top
View user's profile Send private message
ismail.hasan

New User


Joined: 28 Mar 2007
Posts: 21
Location: India

PostPosted: Mon Dec 22, 2008 7:31 pm
Reply with quote

From a Input file which is fetched from the database.
using cast functionality.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Dec 22, 2008 7:42 pm
Reply with quote

ismail.hasan,

You CAN do this in sort. BTW, what is your source table column definition for this? Isn't it possible to do an ORDER by while fetching these values.
Back to top
View user's profile Send private message
ismail.hasan

New User


Joined: 28 Mar 2007
Posts: 21
Location: India

PostPosted: Mon Dec 22, 2008 7:47 pm
Reply with quote

No I am using union. So group by or order by are not possible for the all the fetch in a single strecth
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Dec 22, 2008 8:26 pm
Reply with quote

Quote:
So group by or order by are not possible for the all the fetch in a single strecth
Did you try giving ORDER BY and UNION together? Can you please post here the SQL using 'Code' tags?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Dec 23, 2008 6:42 am
Reply with quote

Hi,

you can try this
Code:
//S1       EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                           
1                                         
5                                         
3                                         
203                                       
100                                       
20                                         
1002                                       
2                                         
200                                       
10                                         
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  SORT FIELDS=(1,04,UFF,A)                 
/*                                         



Gerry
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Dec 23, 2008 9:05 am
Reply with quote

Gerry,

But if the same could be achieved in SQL itself, should n't he be going for that?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Dec 23, 2008 9:29 am
Reply with quote

Hi Arun,

my answer was based on the the subject line
Quote:
Sort Numeric field with spaces


I don't disagree with you, doing it at the source level is always the better option.

Gerry
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top