ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Fixed Length Decimal Value Problem

Post new topic  Reply to topic
 Fixed Length Decimal Value Problem « View previous topic :: View next topic » 
Author Message
Abhi
PostPosted: Thu Mar 10, 2011 3:16 am    Post subject: Fixed Length Decimal Value Problem Reply with quote

Novice

Joined: 10 Mar 2011
Posts: 19

Hi All,
I had a requirement where I needed a decimal field with 6 integral values ( Right justified with padding '0'), a period (.) as decimal separator symbol, and 1 fraction digit (0 in case of complete Integral values).

In the mxsd I created a TDS local element with type xsd:decimal, Physical type = text,Length =8,length unit = character. Right justify, padding character 0 and chose precision (radio button) with Explicit Decimal point-Decimal point always required.

For decimal Input this worked fine but for integral inputs or inputs with 0 as fraction digit say ( 500 or 500.0) the result was "0000500." But what I needed was "000500.0". To my surpise when changed the field as type xsd:string as right justify and padding characters 0 and passed input "500.0" the result was 00000500. I don'y understand this behaviour. kindly anyone explain.

Thanks In Advance,
Abhi
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 10, 2011 3:44 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I had a requirement where I needed a decimal field with 6 integral values ( Right justified with padding '0'), a period (.) as decimal separator symbol, and 1 fraction digit (0 in case of complete Integral values).

Do you need to
a.1) parse some data in this format, or
b.1) write some data in this format?
Quote:
For decimal Input this worked fine but for integral inputs or inputs with 0 as fraction digit say ( 500 or 500.0) the result was "0000500."

a.2) What is your input format?
b.2) What was the value in the message tree ( please post the output from a Trace node )
Quote:
To my surpise when changed the field as type xsd:string as right justify and padding characters 0 and passed input "500.0" the result was 00000500. I don'y understand this behaviour. kindly anyone explain.
Same answers again. You are describing the message flow as a 'black box' with inputs and outputs. You need to understand and describe the problem with reference to the intermediate format ( the message tree). So you need to insert a Trace node just before the output node and examine what the message tree contents are.

As you can probably tell, I am assuming that the answer to the first question is b.1) - you are trying to *write* this format.
Back to top
View user's profile Send private message
Abhi
PostPosted: Thu Mar 10, 2011 9:42 pm    Post subject: Reply with quote

Novice

Joined: 10 Mar 2011
Posts: 19

Hi Kimbert,

Quote:
Do you need to
a.1) parse some data in this format, or
b.1) write some data in this format?


Answe is b.1) Write some data in this format.

Quote:
a.2) What is your input format?
b.2) What was the value in the message tree ( please post the output from a Trace node )


I am assigning a BigDecimal value to this output field. I tried debugging and see that the value in message tree looks perfectly okay...ex: 500.0

And as I said earlier, even after changing the datatype to string in message definition, value is coming as 00000500 for input value 500.0 (padding and justifications are set as explained in my earlier post)
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 11, 2011 2:31 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I am assigning a BigDecimal value to this output field
So you must be using a JavaCompute node. I didn't know that.
Quote:
even after changing the datatype to string in message definition, value is coming as 00000500 for input value 500.0
That's input value "500.0", right? Or are you assigning a Decimal value of 500.0 in the message tree, and relying on the parser to auto-cast from decimal to string?

Either way, the behaviour does sound strange. I would have expected the output to be "000500.0". Might be worth experimenting a little bit more, to see whether you can prove that this is a defect.
Back to top
View user's profile Send private message
Abhi
PostPosted: Fri Mar 11, 2011 4:53 am    Post subject: Reply with quote

Novice

Joined: 10 Mar 2011
Posts: 19

Quote:
That's input value "500.0", right? Or are you assigning a Decimal value of 500.0 in the message tree, and relying on the parser to auto-cast from decimal to string?


Yes it is the input value "500.0" .
Apart from the way I am trying, Is there any other way i can achieve what is required?

Thanks,
Abhi[/quote]
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 11, 2011 5:59 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

If you can't get TDS to do what you need, you could try using a Compute node, and use CAST with a format clause. If you really want to avoid ESQL, then I'm sure Java has some number formatting facilities.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Mar 11, 2011 6:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Could we perhaps see the line of Java code that sets this field?

Can we see a Trace node output or user trace that shows this field being processed by the TDS parser?
Back to top
View user's profile Send private message
paintpot
PostPosted: Fri Mar 11, 2011 8:23 am    Post subject: Reply with quote

Centurion

Joined: 19 Sep 2005
Posts: 112
Location: UK

Change Precision to be '2'.

A similar example from the help gives:
Quote:
If you set Precision to a number greater than the number of fractional digits, the value is padded with extra zeros. For example, the value 12.345 is padded to 12.34500 if you set Precision to 5


Back to top
View user's profile Send private message
Abhi
PostPosted: Mon Mar 14, 2011 2:45 am    Post subject: Reply with quote

Novice

Joined: 10 Mar 2011
Posts: 19

Quote:
Change Precision to be '2'.


Thanks, this works. I needed only 1 value after decimal so I changed precision to 1 and this works for me.[/quote]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Fixed Length Decimal Value Problem
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.