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

Sorting a Field which has Fixed Length But variable digits


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Mon Mar 19, 2012 11:38 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Mar 19, 2012 11:52 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 20, 2012 12:38 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Mar 20, 2012 12:54 am
Reply with quote

UFF saves the day.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Tue Mar 20, 2012 1:52 am
Reply with quote

Thanks for the prompt replies.

Both solutions are working good but the 2nd one requires less efforts.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top