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 » Conversion of integer to hexadecimal

Post new topic  Reply to topic
 Conversion of integer to hexadecimal « View previous topic :: View next topic » 
Author Message
Rohini Iyer
PostPosted: Wed Jan 04, 2006 11:44 pm    Post subject: Conversion of integer to hexadecimal Reply with quote

Newbie

Joined: 04 Jan 2006
Posts: 7

Hi,
I am new to Message Broker 5.0. Can someone help me out

Scenario
----------
Incoming msg - BLOB (actually it is an XML message converted to BLOB using a preceding RCD)
Compute Node -->
Finding the length of the message.
DECLARE MsgLen INTEGER;
SET MsgLen = LENGTH("InputRoot"."BLOB"."BLOB");

Now I need to append this MsgLen to the output blob along with some xml tags.
ie in layman's terms, the output should be
"InputRoot"."BLOB"."BLOB" || '<MessageSize>' || MsgLen in hex or blob (not very sure) || '</MessageSize>'

For the XML portion, I am finding the hex equivalent & hardcoding the same.

so the code is
SET OutputRoot."BLOB"."BLOB" = InputRoot."BLOB"."BLOB" || X'3C4D65737361676553697A653E' || CAST (MsgLen AS BLOB) || X'3C2F4D65737361676553697A653E';

But since the MsgLen needs to be computed each time, I cannot hardcode the value. Casting integer to blob is giving incorrect result. For ex. when the MsgLen was 56. after casting, it gave a value of 8.

Can you please provide a solution ?
Back to top
View user's profile Send private message
shalabh1976
PostPosted: Thu Jan 05, 2006 12:30 am    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

Are you sure the value was 8 and not 38 ?

Anyway in what do you want the value ?
56 in base 10 will get converted to 38 in base 16.
Do you want 56 or 38 in the output ?
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
shalabh1976
PostPosted: Thu Jan 05, 2006 12:38 am    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

You can try a cast to CHAR and then to BLOB.
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Rohini Iyer
PostPosted: Thu Jan 05, 2006 3:50 am    Post subject: Reply with quote

Newbie

Joined: 04 Jan 2006
Posts: 7

Hi,

I was able to cast the integer to character & then cast it to BLOB with CCSID. It works !!!! However without CCSID, it fails....The code snippet is as given below:

DECLARE msgSize CHARACTER;
DECLARE msgLength INTEGER;

SET msgLength = LENGTH (InputRoot."BLOB"."BLOB");
SET msgSize = '<MessageSize>' || CAST(msgLength AS CHARACTER) || '</MessageSize></Envelope>';
SET OutputRoot."BLOB"."BLOB" = CAST ('<Envelope>' AS BLOB CCSID 819) || InputRoot."BLOB"."BLOB" || CAST (msgSize AS BLOB CCSID 819);

Now I am trying the scenario where the input message is XML. I need to find the message size & append this to the input msg.
The code is as follows :
CREATE COMPUTE MODULE Test_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();

DECLARE msgSize INTEGER;
SET msgSize = LENGTH(CAST(InputRoot.XML.TestRun AS BLOB CCSID 819));
SET OutputRoot.XML.Envelope.TestRun = InputRoot.XML.TestRun;
SET OutputRoot.XML.Envelope.MessageSize = msgSize;

RETURN TRUE;
END;

CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;

END MODULE;

The input XML message is <TestRun><A>abcd</A><B>123</B></TestRun>

When I try to cast the input xml as blob (highlighted in blue), InputRoot.XML.TestRun is coming as empty. So the length becomes zero. InputRoot.XML.TestRun is shown as empty when it has child tags.

Is there a way I could retrieve the entire input XML message & convert to BLOB and find the message size ?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jan 05, 2006 4:30 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

In order to get a bit stream of a message tree or subtree, you need to use the ASBITSTREAM function.

In order to properly cast from CHAR to BLOB or the other way, you need to know the CCSID. Fortunately, this is usually in InputRoot.Properties.

Once you have a bit stream of the message, you can use the LENGTH function to get the length of the bitstream.

http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/index.jsp?topic=/com.ibm.etools.mft.doc/ak04860_.htm
_________________
I am *not* the model of the modern major general.
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 » Conversion of integer to hexadecimal
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.