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

sorting of signed fixed decimal no.s in a specific way


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Mon Mar 31, 2008 9:17 pm
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
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 Developer


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

PostPosted: Wed Apr 16, 2008 10:56 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top