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

Sort numeric values stored in character format


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

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 4:53 pm
Reply with quote

Hi All,

Could you please help me in sorting using JCL. My requirement is, I have to sort the records based on the record numbers. The record numbers are presently in decreasing order like 30, 29,... upto 1. Now I want it o be in increasing order like 1,2,...30. Problem here is the record numbers are stored in char format.
I am using the below format in sysin of SORT JCL:

SORT FIELDS=(1,10,CH,A,755,5,CH,A) but it does sortin in following order
1
10
11
12
13
14
15
16
17
18
19
2
20
.
.

I also tried using SORT FIELDS=(1,10,CH,A,755,5,ZD,A), but of no use, icon_sad.gif.

Can anyone help me urgently on this. Appreciate your responses. Thanks.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Apr 17, 2012 4:57 pm
Reply with quote

Hello,

Can you post the input file layout with the code tags.

Note: There is a code tab availiable, where you type the text, use it for better layout understanding.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 5:00 pm
Reply with quote

Hi Naveen,

How to get that code tab; the layout of the file is FB, LRECL=1200, PS FILE.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Apr 17, 2012 5:04 pm
Reply with quote

Hello,

Copy the text of test input record & Paste it here, then look for tab Code beneath the Quick Reply, select the text which you want to tag it, then click the Code tab. Preview & Submit it.

Without seeing your test input record it is hard to assume.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 5:08 pm
Reply with quote

Do you want me to put the whole text of 1200 length of input record?
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Apr 17, 2012 5:11 pm
Reply with quote

Are you sorting the entire 1200 record length

Quote:
SORT FIELDS=(1,10,CH,A,755,5,ZD,A),


Your sort fields says different. icon_exclaim.gif
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 5:15 pm
Reply with quote

Code:
XYZ0199525       32
XYZ0199525       31
[/code]
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Tue Apr 17, 2012 5:16 pm
Reply with quote

I can see what the OP wants to do. The lower numbers, ie; <10, are represented as "1 ", "2 ", etc.

Thus when sorting, "10" comes before "2 ", which is not what is required.

Not sure what the solution is though. Sort is not my speciality.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 5:32 pm
Reply with quote

Hi, Can anyone please help me on this. I need it to get it done asap. Thanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 17, 2012 5:37 pm
Reply with quote

see what happens when you change the 'type' from CH to UFF?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Apr 17, 2012 5:43 pm
Reply with quote

Hi,

this is an example of what you need
Code:
//SORT1 EXEC PGM=SORT                       
//SORTIN  DD *                               
1000000001                                   
1                                           
10                                           
11                                           
12                                           
13                                           
14                                           
15                                           
16                                           
17                                           
18                                           
19                                           
2                                           
20                                           
//SORTOUT DD SYSOUT=*                       
//SYSOUT  DD SYSOUT=*                       
//SYSIN    DD *                             
 SORT FIELDS=(1,10,UFF,A)                   
/*                                           



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

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Apr 17, 2012 5:43 pm
Reply with quote

Kudos, Indeed a perfect reply,I am very thankful to you. My issue is resolved. icon_smile.gif. Thanks one again.

Thank you all for replying on the post. icon_smile.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Tue Apr 17, 2012 11:13 pm
Reply with quote

Glad you got it working but it was NOT JCL that sorted it (your first post) but the sort program. Indeed, in the whole topic, the only JCL is in Gerry's solution.
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 Help with SORT - I need to validate d... DFSORT/ICETOOL 7
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top