Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
archana s

New User

Joined: 31 Mar 2008
Posts: 2

 Posted: Mon Mar 31, 2008 6:43 pm    Post subject: sorting of signed fixed decimal no.s in a specific way Hi, I have records to be sorted in the order - all records with positive amounts (increasing in magnitude) -then all records with negative amounts(increasing in magnitude) The amounts field is declared with the datatype fixed Decimal(11,2) {exact rep of that field in hex{000050} ie 35.00c} {00030C} eg: consider the input as below 400.00d 600.40d 550.00c 200.00d 200.00c 300.00c where d is pos and c is negative I have given the sort cord SORT FIELDS=(756,6,PD,D) [ the field starts at 756 position] the output i got for this is 600.40 400.00 200.00 200cr 300cr 550cr but i want the output to be : 200.00 400.00 600.40 200.00cr 300.00cr 550.00cr (in our system the output cr gets appended automatically for the negative no.s)

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Mon Mar 31, 2008 9:17 pm    Post subject:

That's a very weird way of representing numbers (d for positive instead of negative?).

At any rate, I believe you can use the following DFSORT SORT statement to get what you want:

 Code: SORT FIELDS=(761.4,0.4,BI,D,756,5.4,BI,A)

It sorts the sign (D or C in descending order so the D values come before the C values) and the digits (not including the sign) in ascending order.

When I sorted these values (shown in hex) at 756:

 Code: 00000040000D  00000060040D  00000055000C  00000020000D  00000020001D  00000020002D  00000020019D  00000020020D  00000020000C  00000020001C  00000020002C  00000020019C  00000020020C  00000030000C

I got this output:

 Code: 00000020000D 00000020001D 00000020002D 00000020019D 00000020020D 00000040000D 00000060040D 00000020000C 00000020001C 00000020002C 00000020019C 00000020020C 00000030000C 00000055000C
archana s

New User

Joined: 31 Mar 2008
Posts: 2

 Posted: Wed Apr 16, 2008 8:50 pm    Post subject: Re: sorting of signed fixed decimal no.s in a specific way Hi I have replied long back to this and was waiting on the response ... when i saw today even my reply isn't there... Can you please explain this sort using decimal digits... i have never used such before .. and thanx this logic worked for me .. thanx a lot..
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Wed Apr 16, 2008 10:56 pm    Post subject:

 Code: SORT FIELDS=(761.4,0.4,BI,D,756,5.4,BI,A)

I'm using DFSORT's bit sort notation.

761.4,0.4 - means to sort starting at bit 5 of position 761 for 4 bits. So if 761 has X'5C', it will only sort on C and if 761 has X'2D', it will only sort on D. Thus we are sorting on the sign (C or D) first in descending order.

756,5.4 0 means to sort starting at position 756 for 5 bytes and 4 bits. This sorts on the digits without the sign.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sorting on text - but in non-alphabet... Roy Ware SYNCSORT 5 Wed Aug 23, 2017 9:15 pm How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm Route a product's job to specific lpar vasanthz All Other Mainframe Topics 9 Thu Mar 02, 2017 2:22 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us