Author |
Message
|
alethea |
Posted: Wed Sep 25, 2013 6:05 pm Post subject: Convert into UTF8 |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
Hello All,
I want to convert specific element(IDocStreamData) of XMLNSC Msg (coming in thorough MQInput Node) to UTF 8 format.
Incoming Msg structure: XMLNSC.SapGenericIDocObject.IDocStreamData
IDocStreamData CCSID:913
I am using following in JCN to do it, but I am receiving same data as output.
Could you please help see the UTF output coming out of JCN node.
======================================
MbOutputTerminal out = getOutputTerminal("out");
MbMessage inMessage = contact admin.getMessage();
// create new message
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);
try {
MbElement outRoot = outMessage.getRootElement();
MbElement outSapGenIdocObj = outRoot.getLastChild().getLastChild();
MbElement outIDocStreamData = outSapGenIdocObj.getFirstElementByPath("IDocStreamData");
String ccsid = "912";
Integer ccsidValue = new Integer(ccsid);
byte[] iDocByteStream = outIDocStreamData.toBitstream(null, null, null, 0, ccsidValue, 0);
String convertedData = new String(iDocByteStream, "UTF-8");
outIDocStreamData.setValue(convertedData);
out.propagate(outAssembly);
}
=========================================
Thank you for replying. |
|
Back to top |
|
 |
aggarwal.intouch |
Posted: Wed Sep 25, 2013 11:58 pm Post subject: |
|
|
 Acolyte
Joined: 30 May 2011 Posts: 56 Location: India
|
I am not sure of the JCN but I used the following in my esql for converting the whole message in UTF8 format and it worked.
Code: |
SET OutputRoot.Properties.CodedCharSetId = 1208; |
Last edited by aggarwal.intouch on Thu Sep 26, 2013 12:27 am; edited 1 time in total |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 26, 2013 12:20 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please use [c o d e] tags when posting code snippets - it makes it much easier to read your code. You can use the [edit] button to put them in now, if you like.
Quote: |
I want to convert specific element(IDocStreamData) of XMLNSC Msg (coming in thorough MQInput Node) to UTF 8 format. |
OK, I understand that statement. But what do you want to do with the resulting UTF-8 string? Do you want to emit an XML message, encoded in UTF-8, containing the converted data? _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
alethea |
Posted: Thu Sep 26, 2013 2:05 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
Yes Kimbert.
I need to extract data from IDocStreamData and create an xml msg, topic etc from it and move the readable message in UTF 8 format ahead.
Thanks. |
|
Back to top |
|
 |
alethea |
Posted: Thu Sep 26, 2013 2:13 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
I need to make correction here.
I am getting hex strings as input in IDocStreamData .
So basically the task in JCN is to convert the hex string in UTF-8. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 26, 2013 2:59 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You are trying to do too much work. Message Broker is smarter than you think.
You need to
- Build up your output message in OutputRoot.XMLNSC
- Set OutputRoot.Properties.CodedCharSetId to 1208 ( UTF-8 )
- Let the XMLNSC domain handle the encoding for you _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
alethea |
Posted: Thu Sep 26, 2013 8:10 pm Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
No Kimbert,
Its not working that way. If I just set CCSID in properties folder to 1208, the data in output comes out same as data in input.
The data coming in as hex is latin and I dont want to hardcode the latin code page in esql.
Thanks for your help. |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Sep 26, 2013 10:03 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
What kimbert said above is correct, so maybe if you post a small example of the data you have in IDocStreamData and what you want to convert it to, then we can understand better what your problem is |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 9:49 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
Here is the sample data:
<IDocStreamData>4544495f444334302020303130303030 |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Sep 27, 2013 10:35 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
alethea wrote: |
Here is the sample data:
<IDocStreamData>4544495f444334302020303130303030 |
Which looks like
Code: |
45 44 49 5f 44 43 34 30 20 20 30 31 30 30 30 30
E D I _ D C 2 0 sp sp 0 1 0 0 0 0
|
Does this seem familiar? _________________ 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 |
|
 |
dogorsy |
Posted: Fri Sep 27, 2013 10:36 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
ok, and you want that to come out as :
? |
|
Back to top |
|
 |
kimbert |
Posted: Fri Sep 27, 2013 10:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
so maybe if you post a small example of the data you have in IDocStreamData |
Done. Thanks.
Quote: |
and what you want to convert it to, |
Not done. Please post the exact output that you want to receive.
hint: You are not thinking accurately about this problem. Try describing your input data more accurately. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 10:48 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
If this is the input to compute node: 45 44 49 5f
The output from compute node should be "EDI" with CCSID 1208 in properties for further flows to read it. |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 10:52 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
Yes Dogorsy,
I want to come out as
Code:
EDI_DC40 010000 |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Sep 27, 2013 11:07 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
How does broker convert from one data type to another? _________________ 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 |
|
 |
|