Author |
Message
|
Armageddon123 |
Posted: Wed Aug 03, 2016 2:05 pm Post subject: Clarification on ASBITSTREAM working |
|
|
Acolyte
Joined: 11 Feb 2014 Posts: 61
|
Hi Experts
I have a simple question. , Not able to find out this answer though .
I have to save the json data in Environment and use later
DECLARE TESTMSG CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data) AS CHARACTER CCSID 1208);
This line works fine and saves the json message properly in TESTMSG
but if we use
DECLARE TESTMSG CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data CCSID 1208) AS CHARACTER CCSID 1208);
it saves the hex representation in the TESTMSG
Can you please advise why this difference is happening if we specify or not specify CCSID in ASBITSTREAM function
Upon checking IBM technotes below
https://developer.ibm.com/answers/questions/169394/why-does-the-xml-message-data-in-my-iib-or-wmb-mes.html
The example in that link doesnot use CCSID while doing ASBITSTREAM
As per infocentre of ASBITSTREAM
if CCSID is not specified, then default value will be used.
So not able to clearly understand what is the difference happening between first and second line of code
Can you please provide some thoughts why giving CCSID in example2 is saving the hex data and not the proper text data.. Thanks |
|
Back to top |
|
 |
Armageddon123 |
Posted: Mon Aug 22, 2016 3:21 pm Post subject: |
|
|
Acolyte
Joined: 11 Feb 2014 Posts: 61
|
I certainly do not want to be the bad guy here!. But what is the harm in giving one more try!
Did any experts got a chance to read this and think it is worthy to give some opinion?! |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Aug 22, 2016 10:57 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
1) Posting at 11:21pm (In my timezone) is IMHO a quiet time around here. Most regulars are not working
2) We don't have an SLA for responding. We all (or most) have day jobs to do.
3) If you have one construct that works then use it. If you absolutely must have an explanation for why the other one does not then it might time to raise a PMR. Then you can get the definitve answer from IBM. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 23, 2016 3:55 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What does ASBITSTREAM return? What would the affect of using a CCSID with ASBITSTREAM do to that return value?
What is the difference in what you get back from ASBITSTREAM between your two methods if you don't cast it as a CHAR? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Craig B |
Posted: Mon Sep 19, 2016 11:14 pm Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
You mention that you are saving the message as text in the Environment tree and that one variation stores the value as text but the other saves it as Hex bytes. I can't recreate you issue. In a compute node I tried your two variations:
DECLARE TESTMSG1 CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data) AS CHARACTER CCSID 1208);
DECLARE TESTMSG2 CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data CCSID 1208) AS CHARACTER CCSID 1208);
SET Environment.Result1 = TESTMSG1;
SET Environment.Result2 = TESTMSG2;
A trace node capturing the Enviroment Tree shows:
( ['MQROOT' : 0x2500ffb0]
(0x03000000:NameValue):Result1 = '{"data":[{"field1":"value1","field2":"value2"}]}' (CHARACTER)
(0x03000000:NameValue):Result2 = '{"data":[{"field1":"value1","field2":"value2"}]}' (CHARACTER)
)
I tried multiple input CCSIDs for the JSON message and the result was always the same.
Can you run this quick test in your Environment and show the output of your trace node? _________________ Regards
Craig |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Sep 20, 2016 3:54 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The only times I've gotten a value like x'HEXBYTES' is when I have tried to display a blob as a string without using a CCSID in converting to a string. I suppose it might also be when the message CCSID doesn't match the CCSID being used with the ASBITSTREAM.
As Craig B says, you need to be able to give us more information so we can help you more. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Craig B |
Posted: Tue Sep 20, 2016 4:14 am Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
mqjeff makes a good point in the last post.
If you had mis-remembered where you had accidentally omitted the CCSID parameter then the following would give the behaviour you have seen:
DECLARE TESTMSG1 CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data) AS CHARACTER);
DECLARE TESTMSG2 CHARACTER CAST (ASBITSTREAM(InputRoot.JSON.Data) AS CHARACTER CCSID 1208);
SET Environment.Result1 = TESTMSG1;
SET Environment.Result2 = TESTMSG2;
results in:
( ['MQROOT' : 0x2525b310]
(0x03000000:NameValue):Result1 = 'X'7b2264617461223a5b7b226669656c6431223a2276616c756531222c226669656c6432223a2276616c756532227d5d7d'' (CHARACTER)
(0x03000000:NameValue):Result2 = '{"data":[{"field1":"value1","field2":"value2"}]}' (CHARACTER)
)
Here the CCSID was not used on the CAST.
When CCSID is not used on a CAST it just gives a text representation of the BLOB it was passed. CCSID gives it the extra information to turn hex bytes into characters according the CCSIDs code points. _________________ Regards
Craig |
|
Back to top |
|
 |
|