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 » What would be the best way ( TRIM leading Zeros )

Post new topic  Reply to topic
 What would be the best way ( TRIM leading Zeros ) « View previous topic :: View next topic » 
Author Message
mq_developer
PostPosted: Mon Jan 27, 2003 9:58 am    Post subject: What would be the best way ( TRIM leading Zeros ) Reply with quote

Voyager

Joined: 18 Feb 2002
Posts: 82

Gang,

I creating XML message from incoming MRM input fields , some of the input fields are defined as FLOAT ( ESQL data type) corresponds to V99 COMP-3 fields in COBOL .

Customer wants to have following transformation

0000111.00 to be 111.00 , similar lines if incoming value is zero
0000000.00 to be 0.00

Rightnow what i am doing is CAST (InputField as CHAR) and TRIM LEADING '0' from that , but this would work for all cases except in case of 0000000.00 where it would result in .00 instead of 0.00

Now am using a IF condition to handle Zero (0000000.00) cases , but doesnt look like a better way to me ....

Need your ideas on this .....

Regards,
Ram
Back to top
View user's profile Send private message
yaakovd
PostPosted: Mon Jan 27, 2003 11:23 am    Post subject: Reply with quote

Partisan

Joined: 20 Jan 2003
Posts: 319
Location: Israel

DECLARE I INT;
DECLARE C1 CHAR;
SET C1 = "InputRoot".<your input MRM element>;
SET I = CAST( SUBSTRING( C1 FROM 1 FOR POSITION('.' IN C1)-1 ) AS INT);
SET OutputRoot.XML."field_1" = CAST ( I AS CHAR) || SUBSTRING( C1 FROM POSITION('.' IN C1) );

All depends how much you trust on your input.
If you not sure that your input is numeric, you can use my code from topic
http://www.mqseries.net/phpBB2/viewtopic.php?t=7231 befor casting to INT.
It can be like this:

IF(POSITION('.' IN C1) = 0)THEN
-- remove this case if it impossible for you: input = 0000000000
-- or add what you want to do
ELSE
IF(POSITION('.' IN C1) > 1)THEN
SET I = CAST( SUBSTRING( C1 FROM 1 FOR POSITION('.' IN C1)-1 ) AS INT);
SET OutputRoot.XML."field_1" = CAST ( I AS CHAR) || SUBSTRING( C1 FROM POSITION('.' IN C1) );
ELSE
-- remove this case if it impossible for you: input = .000000000
-- or add what you want to do
END IF;
END IF;
_________________
Best regards.
Yaakov
SWG, IBM Commerce, Israel
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » What would be the best way ( TRIM leading Zeros )
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.