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

Author Message
Aneesh

New User

Joined: 30 Sep 2006
Posts: 60

Posted: Thu Nov 12, 2009 4:35 am    Post subject: DIV operation round down

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.

Frank Yaeger

DFSORT Moderator

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

Posted: Thu Nov 12, 2009 4:55 am    Post subject:

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.
Aneesh

New User

Joined: 30 Sep 2006
Posts: 60

 Posted: Thu Nov 12, 2009 6:03 am    Post subject: Reply to: DIV operation round down Thanks a lot, Frank . That works fine for my purposes.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Utility for search operation Gopalakrishna551 TSO/ISPF 11 Wed Jan 03, 2018 11:07 am Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm Joinkeys operation betwen VB and FB file Susanta SYNCSORT 4 Sun Sep 25, 2016 9:49 pm how to eliminate records from operati... PUMA DFSORT/ICETOOL 5 Tue Dec 23, 2014 4:42 pm Operation with 3 files sun_job DFSORT/ICETOOL 5 Wed Oct 15, 2014 6:46 pm

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