|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Conversion of integer to hexadecimal |
« View previous topic :: View next topic » |
Author |
Message
|
Rohini Iyer |
Posted: Wed Jan 04, 2006 11:44 pm Post subject: Conversion of integer to hexadecimal |
|
|
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 |
|
 |
shalabh1976 |
Posted: Thu Jan 05, 2006 12:30 am Post subject: |
|
|
 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 |
|
 |
shalabh1976 |
Posted: Thu Jan 05, 2006 12:38 am Post subject: |
|
|
 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 |
|
 |
Rohini Iyer |
Posted: Thu Jan 05, 2006 3:50 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Thu Jan 05, 2006 4:30 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|