Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sorting a Field which has Fixed Length But variable digits

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ksk

Active User


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

PostPosted: Mon Mar 19, 2012 11:38 pm    Post subject: Sorting a Field which has Fixed Length But variable digits
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: 6967
Location: porcelain throne

PostPosted: Mon Mar 19, 2012 11:52 pm    Post subject:
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    Post subject: Reply to: Sorting a Field which has Fixed Length But variabl
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: 6967
Location: porcelain throne

PostPosted: Tue Mar 20, 2012 12:54 am    Post subject:
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: 356
Location: New York

PostPosted: Tue Mar 20, 2012 1:52 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us