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 » Cast from string to Decimal

Post new topic  Reply to topic
 Cast from string to Decimal « View previous topic :: View next topic » 
Author Message
eai143
PostPosted: Tue Apr 09, 2013 11:37 pm    Post subject: Cast from string to Decimal Reply with quote

Apprentice

Joined: 16 Aug 2006
Posts: 28

Hi,

How pattern should be mentioned, when casting a string to decimal.
there may be 2 decimal points or 3.

I'm trying with '##0.00'.
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Wed Apr 10, 2013 5:44 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

What problem are you having with this? What have you tried?

I suspect you want ##0.00# but can't tell from what you have said.

Provide your
Code:
code
and results and questions if you want more help
Back to top
View user's profile Send private message
eai143
PostPosted: Fri Apr 12, 2013 1:40 am    Post subject: Reply with quote

Apprentice

Joined: 16 Aug 2006
Posts: 28

vmcgloin wrote:
What problem are you having with this? What have you tried?

I suspect you want ##0.00# but can't tell from what you have said.

Provide your
Code:
code
and results and questions if you want more help


I'm getting a string value, say 00002200 from input. I want 22.00 as output. Sometimes the decimal points may be 3 or 4.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Apr 12, 2013 3:07 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

eai143 wrote:
I'm getting a string value, say 00002200 from input. I want 22.00 as output. Sometimes the decimal points may be 3 or 4.


What does that mean, "sometimes the decimal points may be 3 or 4"?

That sometimes the number is 00022000 or 00220000?

Or that sometimes the number should be 22.000 or 22.0000?

Or that when the number is 00002200, sometimes the output should be 220.0 or 2200.0 ?
Back to top
View user's profile Send private message
eai143
PostPosted: Mon Apr 15, 2013 3:42 am    Post subject: Reply with quote

Apprentice

Joined: 16 Aug 2006
Posts: 28

mqjeff wrote:
eai143 wrote:
I'm getting a string value, say 00002200 from input. I want 22.00 as output. Sometimes the decimal points may be 3 or 4.


What does that mean, "sometimes the decimal points may be 3 or 4"?

That sometimes the number is 00022000 or 00220000?

Or that sometimes the number should be 22.000 or 22.0000?

Or that when the number is 00002200, sometimes the output should be 220.0 or 2200.0 ?


Say for example, In my imput message, I will be getting 3 Values, say 00002200, 00004400 and 00006600 .
I want the output as 22.00(2 decimal points), 4.400(3 decimal points) and 0.6600(4 decimal points).
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Apr 15, 2013 4:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Sounds like a numeric field from SAP. Of course you know that there is no sense or value to the field without its associated Unit of Measure field.
This is the only way you can determine the actual value of the data.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
vmcgloin
PostPosted: Mon Apr 15, 2013 6:49 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

You must know the decimal places for each field. Based on that you can dynamically choose or define the pattern to use for your cast within you ESQL.
Back to top
View user's profile Send private message
eai143
PostPosted: Mon Apr 15, 2013 9:43 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Aug 2006
Posts: 28

vmcgloin wrote:
You must know the decimal places for each field. Based on that you can dynamically choose or define the pattern to use for your cast within you ESQL.


I tried with '##0.00' pattern for 2 decimal points. But its not working.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Apr 16, 2013 4:24 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

if your output XML is not typed, any decimal value like 3.00 that follows a pattern like #.00 and in fact could be represented by an integer may be displayed as an integer in XML as there is no difference as to the value...

I suggest you cast your numeric value to a string using the format clause and then assign the string to the message tree.

Hope this helps...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
adubya
PostPosted: Tue Apr 16, 2013 4:32 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Well done for actually trying something, not everyone does before coming on here

It would help us help you though if you posted up the
Code:
code
snippet you've tried.
Back to top
View user's profile Send private message Send e-mail
dogorsy
PostPosted: Tue Apr 16, 2013 5:31 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

eai143 wrote:
mqjeff wrote:
eai143 wrote:
I'm getting a string value, say 00002200 from input. I want 22.00 as output. Sometimes the decimal points may be 3 or 4.


What does that mean, "sometimes the decimal points may be 3 or 4"?

That sometimes the number is 00022000 or 00220000?

Or that sometimes the number should be 22.000 or 22.0000?

Or that when the number is 00002200, sometimes the output should be 220.0 or 2200.0 ?


Say for example, In my imput message, I will be getting 3 Values, say 00002200, 00004400 and 00006600 .
I want the output as 22.00(2 decimal points), 4.400(3 decimal points) and 0.6600(4 decimal points).


you will need 3 different patterns , one for each case. That is supposing that the number of decimal places is FIXED, i.e. always 2 for the first number, always 3 for the 2nd and always 4 for the last. Otherwise you can try randomly the number of decimal places, cross your fingers and hope you get it right
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Tue Apr 16, 2013 12:28 pm    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

fjb_saper wrote:
if your output XML is not typed, any decimal value like 3.00 that follows a pattern like #.00 and in fact could be represented by an integer may be displayed as an integer in XML as there is no difference as to the value...

I suggest you cast your numeric value to a string using the format clause and then assign the string to the message tree.

Hope this helps...


This is a good point but it is still the correct value. However you still need to tell us in what way it is not working and the code that is causing that output. You have got 4 people interested enough to offer help - but that won't last if you don't help us to help you .
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 » Cast from string to Decimal
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.