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 of signed fixed decimal no.s in a specific way

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

New User


Joined: 31 Mar 2008
Posts: 2
Location: Hyderabad

PostPosted: Mon Mar 31, 2008 6:43 pm    Post subject: sorting of signed fixed decimal no.s in a specific way
Reply with quote

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)
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Mon Mar 31, 2008 9:17 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
archana s

New User


Joined: 31 Mar 2008
Posts: 2
Location: Hyderabad

PostPosted: Wed Apr 16, 2008 8:50 pm    Post subject: Re: sorting of signed fixed decimal no.s in a specific way
Reply with quote

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..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Apr 16, 2008 10:56 pm    Post subject:
Reply with quote

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.
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 How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
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 Route a product's job to specific lpar vasanthz All Other Mainframe Topics 9 Thu Mar 02, 2017 2:22 am
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am


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