uvregen - Decimal places greater than 15

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
russ356
Charter Member
Charter Member
Posts: 38
Joined: Tue Jun 07, 2005 6:58 am

uvregen - Decimal places greater than 15

Post by russ356 »

I have financial values coming in from a source that is 30 decimal places. I need to round these to 20 decimal places. I read some posts on changing the EXACTNUMERIC setting in the uvconfig file. Which I done but it did not work. Here is what I have done so far.

Stopped the DS services.
Made sure everyone was out.
Changed the uvconfig.
Ran the uvregen
Started the DS services.

Here is an example of the input file, what I need, and what I currently am getting.

Ex.
12.123456789012345678901234567890

What I need is
12.12345678901234567890

Currently what I am getting is.
12.1234567890123

Can anyone tell me what I am doing wrong or what I can do to solve this problem. ?

I am running DS 7.5.1 on Windows 2003 Server.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Are you using View Data on the Sequential stage to see the result? Verify your Scale is set appropriately as well. Maybe View Data is wrong but it's correctly being read. Write the output to another Sequential file into two different columns: one as text, the other as DECIMAL with the correct scale. See if it's good anywhere. Let us know, Ray Wurlod is standing next to me, he verifies that EXACTNUMERIC is good to 57.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
russ356
Charter Member
Charter Member
Posts: 38
Joined: Tue Jun 07, 2005 6:58 am

Post by russ356 »

I have viewed the data and it is correct. I have confirmed that the precision and scale are also correct. When I output the fields as varchar or decimal than the output is 30 decimal places long. Which is what I set the EXACTNUMERIC setting to in the uvconfig. I get the problem when I try to use the FIX function or any other to round it to 20 decimal. Here is the fix function I have coded in my job. Which only returns 15 total places. So I guess it technically works but how can I get it to round to 20 decimal places.

Code: Select all

Fix(DSLink3.Test2,20,0)
russ356
Charter Member
Charter Member
Posts: 38
Joined: Tue Jun 07, 2005 6:58 am

Post by russ356 »

Well I have found a solution for my problem. It's quite ugly and crude but it works. Below is a routine I wrote to round a number greater than 10. Please take a look and let me know your thoughts on the code or the solution. I'm not happy with it and would love to explore a better solution but I have a deadline.
Thanks

Code: Select all

* Arguments
* dblNumber -  Number being rounded
* intDecimals - Number of decimals positions

* Find the decimal position
   decimalposition = INDEX(dblNumber, ".", 1)
* Length of number
   lenNum = len(dblNumber)

NumPos = dblNumber[decimalposition + intDecimals, 1]
EvalNum = dblNumber[decimalposition + intDecimals + 1, 1]


IF EvalNum >= 5 THEN 
   IF NumPos < 9 THEN 
      retVal = dblNumber[1,decimalposition + intDecimals - 1] : NumPos + 1
   END ELSE
      *  If the factor is 9 perform a loop downwards to round up the next value less than 9
      x = intDecimals   
         FOR i = 1 to lenNum
            IF dblNumber[decimalposition + x,1] = 9 THEN
               goto NextI
            END ELSE
               retVal = dblNumber[1,decimalposition + x - 1] : dblNumber[decimalposition + x,1] + 1
               goto Out 
            END
NextI:
         x = x - 1 
         NEXT i
   END
END ELSE
   retVal = dblNumber[1, decimalposition + intDecimals]
END

Out:
Ans = retVal
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Sorry for not keeping up with this thread, we're at the IOD conference and our attention wanders. Look in your DS BASIC manual for SDIV, or string divide. It may be the simpler method for dealing with your issue. See if that works and can you let me know?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As Ken notes, when working with large numbers like that you need to stick with the 'string math' functions. SDIV is one, there are equivalents for the others as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Put the compiler declaration PRECISION 14 at the top of your code.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply