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 » Number Formatting to output MRM

Post new topic  Reply to topic
 Number Formatting to output MRM « View previous topic :: View next topic » 
Author Message
hellobond070
PostPosted: Mon Aug 16, 2010 4:19 pm    Post subject: Number Formatting to output MRM Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

I have got a issue with data formatting.

Input is an XML files with one of the data element passing the value say '54.34'.

I need this to be formatted in 10 characters including the dot.

so the output should look like '0000054.34'

I tried
Code:
DECLARE pattern CHARACTER '0000000.00';

and then used CAST
Code:
SET OutputRoot.MRM.SKU_QTY = CAST(source AS CHARACTER FORMAT pattern);

where source is the input xml element.

I am getting the below error :

Quote:
(0x01000000:Name ):ParserException = (
(0x03000000:NameValue):File = 'F:\build\S610_P\src\MTI\MTIforBroker\MtiImbParser2\MtiImbValueValidator.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 1859 (INTEGER)
(0x03000000:NameValue):Function = 'MtiImbValueValidator::basicValidate' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPv610' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 5164 (INTEGER)
(0x03000000:NameValue):Text = 'Exception thrown when casting to the expected logical type' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'SKU_QTY' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'INTEGER' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'STRING' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '54.0' (CHARACTER)
)
(0x01000000:Name ):ConversionException = (
(0x03000000:NameValue):File = 'F:\build\S610_P\src\cpi\bsutils\datacnv.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 621 (INTEGER)
(0x03000000:NameValue):Function = 'DataCnv::StrToInt64' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPv610' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 5505 (INTEGER)
(0x03000000:NameValue):Text = 'CPI Converter Input Data Invalid' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'string' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '54.0' (CHARACTER)
)
)
)

Please advise.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 16, 2010 7:40 pm    Post subject: Reply with quote

Grand High Poobah

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

For the format you gave, you would need to cast to a double. That format is decimal and as such not castable to an Integer.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hellobond070
PostPosted: Mon Aug 16, 2010 8:43 pm    Post subject: Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

So should it be as below

Quote:
DECLARE pattern DOUBLE '0000000.00';


OR

SET OutputRoot.MRM.SKU_QTY = CAST(source AS DOUBLE FORMAT pattern);

Please suggest.
Back to top
View user's profile Send private message
hellobond070
PostPosted: Tue Aug 17, 2010 7:13 am    Post subject: Reply with quote

Centurion

Joined: 18 Nov 2009
Posts: 118

I read a few posts and I feel this kind of conversion is not possible.

Let me redefine my problem

Input is XML file which I parse using XMLNSC. Suppose one of the element quantitiy has "54.0", the output is a CWF MRM.

The output field should look like "00000054.00" which is of 10 characters.

Can someone still advise if they it is possible
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Aug 17, 2010 9:50 am    Post subject: Reply with quote

Grand High Poobah

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

That should all be possible.
Just remember that casting if often a matter of logic and perception.
So you can cast a double or integer to a format "000.00" but you can cast "53.55" or "54.00" only to a double. You can then cast that double to an integer, loosing some precision...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Aug 23, 2010 2:57 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Let me redefine my problem
Input is XML file which I parse using XMLNSC.

Being picky, the input format is not relevant. The MRM CWF writer will produce an output bitstream using the the message tree and the message set.
Quote:
Suppose one of the element quantitiy has "54.0"
Which data type is this. Is it a string or a decimal or a float?
Hint: if you have not set the XMLNSC parser option 'Build tree using XML schema' then it will be a string.

Quote:
The output field should look like "00000054.00" which is of 10 characters.
That looks like a number that has been written with two decimal places, right-justified and padded with zeros. You need to:
a) CAST the input CHARACTER to a decimal or float. You can't control the output format accurately unless you first convert the string to a number.
b1) CAST the resulting number to a CHARACTER using CAST with a FORMAT clause.
or
b2) put the float/decimal into OutputRoot.MRM.xxx and change your message definition file to expect a number. Set the CWF properties to control the number of decimal places and the padding/justification.

b2) would be my choice, because it removes physical formatting from the message flow and puts it where it belongs ( in the message set ).

If you have a schema for your input XML then you can enable validation, set 'Build tree using XML Schema' and avoid having to do the CAST in a).
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 » Number Formatting to output MRM
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.