MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting on Left-justified numeric

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
flatearther
Beginner


Joined: 19 Apr 2007
Posts: 13
Topics: 2
Location: Bethesda, MD

PostPosted: Wed Oct 21, 2009 10:53 pm    Post subject: Sorting on Left-justified numeric Reply with quote

Quick question - I have a file with a sequence number which is numeric and unfortunately left-justified (with trailing spaces).

Is it possible to sort using this field as the sort key (descending)?

Specifying the field as CH or BI doesn't work, for instance:

Seq No
---------
11
1234
111111

won't sort to
111111
1234
11

because of the left-justification.
Any ideas?
Back to top
View user's profile Send private message
flatearther
Beginner


Joined: 19 Apr 2007
Posts: 13
Topics: 2
Location: Bethesda, MD

PostPosted: Wed Oct 21, 2009 11:07 pm    Post subject: Reply with quote

Just to clarify - I want to sort on the numerical values of the field (descending) so I want the sort outcome to be:

Seq No
---------
111111
1234
11

but the left justification is messing this up:

Seq No
---------
1234
111111
11
Back to top
View user's profile Send private message
Ram
Beginner


Joined: 12 Jan 2004
Posts: 53
Topics: 12

PostPosted: Thu Oct 22, 2009 3:11 am    Post subject: Reply with quote

If you have DFSort installed, use the justify feature.

e.g.

OPTION COPY
OUTREC FIELDS=(1,30,JFY=(SHIFT=RIGHT))

Once its right justified, you can sort it accordingly.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Oct 22, 2009 10:02 am    Post subject: Reply with quote

flatearther,

Ram has the right idea but his example shows OUTREC which is executed AFTER sorting.

So use the following DFSORT JCL to get the desired results

Code:

//STEP0100 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                           
11                                       
1234                                     
111111                                   
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  SORT FIELDS=(1,6,UFF,D)                 
  INREC OVERLAY=(1,6,JFY=(SHIFT=RIGHT))   
//*


This will the contents of the first 6 bytes as right justified and sort that on descending sequence.
Code:

111111
  1234
    11


But if you want to retain the left shifted data then add this OUTREC statement

Code:

OUTREC OVERLAY=(1,6,JFY=(SHIFT=LEFT))


This will put the data left justified
Code:

111111
1234   
11     

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
flatearther
Beginner


Joined: 19 Apr 2007
Posts: 13
Topics: 2
Location: Bethesda, MD

PostPosted: Thu Oct 22, 2009 5:30 pm    Post subject: Reply with quote

That's works great! Thanks a lot for your help.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Oct 23, 2009 10:33 am    Post subject: Reply with quote

You don't need the INREC or OUTREC statement. Sorting with the UFF format will handle this without any need for JFY. So the DFSORT job would just be:

Code:

//S1    EXEC  PGM=SORT               
//SYSOUT    DD  SYSOUT=*             
//SORTIN DD *                         
11                                   
1234                                 
111111
/*                               
//SORTOUT DD SYSOUT=*                 
//SYSIN    DD    *                   
  SORT FIELDS=(1,6,UFF,D)             
/*


And SORTOUT would have:

Code:

111111     
1234       
11         

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group