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

DIV operation round down


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

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Thu Nov 12, 2009 4:35 am
Reply with quote

Hi,

I have an FB file of length 80 that has a key field, a value field and a multiple field. I need to sort the file in the order of the lowest unit value field record. Unit value is the value field divided by the multiple.

Key field - numeric 10 bytes
Value field - numeric 15 bytes
Multiple feild - numeric 5 bytes

000000000100000000000010100003
000000000100000000000010000003
000000000100000000000007500001

I am using a sort card to divide the value/multiple and then sort on the divided value.

Code:

  INREC FIELDS=(1,30,(11,15,ZD,DIV,26,5,ZD))
  SORT FIELDS=(1,10,ZD,A,31,15,CH,A)       


When i am doing this, i am facing issues with rounding down in the division operation. Value 100 with a multiple of 3 and value 101 with a multiple of 3 both give 33 as output, although i want the sorted order to have 100 with value 3 to come first.

Is there a way around this?

Thanks,
Aneesh.
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: Thu Nov 12, 2009 4:55 am
Reply with quote

You aren't really having trouble with rounding down. You're having trouble with the integer result DFSORT gives for DIV.

You can scale the value by +100 to get more significance in the integer result. For example (assuming you don't really want to keep the unit value):

Code:

  INREC OVERLAY=(81:(11,15,ZD,MUL,+100),     
      DIV,26,5,ZD,TO=ZD,LENGTH=15)           
  SORT FIELDS=(1,10,ZD,A,81,15,CH,A)         
  OUTREC BUILD=(1,80)                       


Now the unit value will be 000000000003333 for 100/3 and 000000000003366 for 101/3, so it will sort correctly, and your output will be:

Code:

000000000100000000000010000003   
000000000100000000000010100003   
000000000100000000000007500001   


If you want something else for the output, you need to show what you want exactly.
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Thu Nov 12, 2009 6:03 am
Reply with quote

Thanks a lot, Frank icon_smile.gif. That works fine for my purposes.
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 An write operation error - ABENDED S0... COBOL Programming 3
No new posts Utility for search operation TSO/ISPF 11
No new posts Joinkeys operation when key1 and key2... DFSORT/ICETOOL 5
No new posts Joinkeys operation betwen VB and FB file SYNCSORT 4
No new posts how to eliminate records from operati... DFSORT/ICETOOL 5
Search our Forums:

Back to Top