Author |
Message
|
eai143 |
Posted: Tue Apr 09, 2013 11:37 pm Post subject: Cast from string to Decimal |
|
|
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 |
|
 |
vmcgloin |
Posted: Wed Apr 10, 2013 5:44 am Post subject: |
|
|
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
and results and questions if you want more help  |
|
Back to top |
|
 |
eai143 |
Posted: Fri Apr 12, 2013 1:40 am Post subject: |
|
|
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
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 |
|
 |
mqjeff |
Posted: Fri Apr 12, 2013 3:07 am Post subject: |
|
|
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 |
|
 |
eai143 |
Posted: Mon Apr 15, 2013 3:42 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Mon Apr 15, 2013 4:39 am Post subject: |
|
|
 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 |
|
 |
vmcgloin |
Posted: Mon Apr 15, 2013 6:49 am Post subject: |
|
|
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 |
|
 |
eai143 |
Posted: Mon Apr 15, 2013 9:43 pm Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Tue Apr 16, 2013 4:24 am Post subject: |
|
|
 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 |
|
 |
adubya |
Posted: Tue Apr 16, 2013 4:32 am Post subject: |
|
|
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
snippet you've tried. |
|
Back to top |
|
 |
dogorsy |
Posted: Tue Apr 16, 2013 5:31 am Post subject: |
|
|
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 |
|
 |
vmcgloin |
Posted: Tue Apr 16, 2013 12:28 pm Post subject: |
|
|
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 |
|
 |
|