Author |
Message
|
dogorsy |
Posted: Fri Sep 27, 2013 11:15 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
alethea wrote: |
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. |
so, you do not want to convert CCSIDs, you have a character string, say "4544" , that you want to convert ( fold, pack ) into another character string, ie, "ED" |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 11:15 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
smdavies99,
Please see the first post.
My initial question is: how should I do this with JCN.
It would be great if you can help by putting aside words like 'silly questions'.
If you are able to get the output the way I want then please let me know what did you do to get it. |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 11:17 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
|
Back to top |
|
 |
dogorsy |
Posted: Fri Sep 27, 2013 11:19 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
alethea wrote: |
smdavies99,
Please see the first post.
My initial question is: how should I do this with JCN.
It would be great if you can help by putting aside words like 'silly questions'.
If you are able to get the output the way I want then please let me know what did you do to get it. |
Hi Alethea,
I don't think smdavies99 meant that as an explicit message to you. It is part of his footnote and is appended to every post he makes. |
|
Back to top |
|
 |
alethea |
Posted: Fri Sep 27, 2013 11:26 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
Oh.
In that case smdavies99, please pardon me. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Sep 27, 2013 12:06 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
OK, so your input data is hexBinary. You need to do this:
- convert the hexBinary to a byte array ( http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java )
- convert the byte array to a String. Your Java sample shows that you know how to do that, but which encoding will you choose? How do you know that it is the encoding that the sender used when they created that byte array?
- Put the string into your output message. Do not attempt to convert it to UTF-8 at this point.
- Set OutputRoot.Properties.CodedCharSetId to 1208.
- Propagate the message to the output terminal
See what I mean about accurate thinking? _________________ 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 |
|
 |
smdavies99 |
Posted: Fri Sep 27, 2013 12:12 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
alethea wrote: |
Oh.
In that case smdavies99, please pardon me. |
No problem. What I think that myself and a few others were tyring to ask is that why are you trying to do this in a JCN when ESQL will do this very simply.
If there is a genuine business reason for using a JCN then ok. However we have had posts here where the reason for using a JCN was
' We are not allowed to use ESQL Compute Nodes because some consultant said that we shouldn't'. _________________ 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 |
|
 |
kimbert |
Posted: Fri Sep 27, 2013 12:20 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I agree with smdavies99. Java can be the correct choice of language, but in this case ESQL would be simpler because it is designed for this type of task.
- Add the string x' to the start of the input field value
- CAST resulting CHARACTER variable to BLOB
- CAST the BLOB to CHARACTER
- Assign the resulting CHARACTER value to OutputRoot.XMLNSC
Much simpler, I think. _________________ 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 |
|
 |
dogorsy |
Posted: Fri Sep 27, 2013 1:06 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
kimbert wrote: |
I agree with smdavies99. Java can be the correct choice of language, but in this case ESQL would be simpler because it is designed for this type of task.
- Add the string x' to the start of the input field value
- CAST resulting CHARACTER variable to BLOB
- CAST the BLOB to CHARACTER
- Assign the resulting CHARACTER value to OutputRoot.XMLNSC
Much simpler, I think. |
I agree with using ESQL, but it is even simpler than that:
Code: |
DECLARE myBlob BLOB InputRoot.XMLMSC...whatever...IDocStreamData; |
( The line above does an implicit CAST from char to blob ),
and then CAST myBlob to char , with the correct CCSID ... for the OP to work it out. |
|
Back to top |
|
 |
kimbert |
Posted: Sat Sep 28, 2013 9:27 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
...but not *that* simple ( unless I'm missing something, which is quite possible ).
The incoming field is not a BLOB. It is a byte array that has been encoded as an xs:hexBinary. To convert it to an ESQL BLOB it is necessary to add the leading x' ( as required by ESQL's BLOB format ) and CAST to BLOB. _________________ 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 |
|
 |
kimbert |
Posted: Sat Sep 28, 2013 9:29 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
@alethea: This field is an EDI message of some kind. EDI is a text format. Why did the sender decide to encode this text as xs:hexBinary? Are you sure that it is safe for your message flow to reverse that decision when sending the message onwards? _________________ 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 |
|
 |
dogorsy |
Posted: Sat Sep 28, 2013 9:44 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
kimbert wrote: |
...but not *that* simple ( unless I'm missing something, which is quite possible ).
The incoming field is not a BLOB. It is a byte array that has been encoded as an xs:hexBinary. To convert it to an ESQL BLOB it is necessary to add the leading x' ( as required by ESQL's BLOB format ) and CAST to BLOB. |
agree. but difficult to say what to do when the problem is not properly described. And I think that is the main issue here. The OP posted some java code saying it is not working, mentioning CCSIDs, etc. rather than describing: this is my input--> I want this to be my output.
My guess was that she is getting a char string that wants converted to a char string.
by the way, if the incoming field is a char string (as alethea suggested ) then the cast is done implicitly. but again, difficult to tell... |
|
Back to top |
|
 |
rekarm01 |
Posted: Sat Sep 28, 2013 1:20 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
kimbert wrote: |
...but not *that* simple ( unless I'm missing something, which is quite possible ).
The incoming field is not a BLOB. It is a byte array that has been encoded as an xs:hexBinary. To convert it to an ESQL BLOB it is necessary to add the leading x' ( as required by ESQL's BLOB format ) and CAST to BLOB. |
When using CAST to convert a hexbinary string from CHARACTER to BLOB, the leading/trailing X'...' are optional:
Quote: |
... the string must itself contain two-character hexadecimal digits of the form X'hhhhhh' or hhhhhh (where h can be any hexadecimal characters). |
When using CAST to convert the resulting BLOB to a (non-hexbinary) CHARACTER string, the CAST requires a CCSID clause, specifying whatever CCSID was used to initially generate the hexbinary, (which is not necessarily the same as the input CCSID of the message itself, or the desired output CCSID of the message). |
|
Back to top |
|
 |
alethea |
Posted: Mon Sep 30, 2013 1:12 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
kimbert wrote: |
Are you sure that it is safe for your message flow to reverse that decision when sending the message onwards? |
Yes |
|
Back to top |
|
 |
alethea |
Posted: Mon Sep 30, 2013 1:33 am Post subject: |
|
|
Apprentice
Joined: 30 Jul 2007 Posts: 45
|
dogorsy wrote: |
agree. but difficult to say what to do when the problem is not properly described. And I think that is the main issue here. The OP posted some java code saying it is not working, mentioning CCSIDs, etc. rather than describing: this is my input--> I want this to be my output.
My guess was that she is getting a char string that wants converted to a char string.
by the way, if the incoming field is a char string (as alethea suggested ) then the cast is done implicitly. but again, difficult to tell... |
I am using SAPInputNode.
Once the msg comes out of SAPInput Node from SAP its structure is:
--Properties
-- Msgset --<Value>
--Transactional--true
--DataObject
--SAPGenericIdocObject
--SAPTransactionId
--IDocStreamData
--IDocType
--LocalEnvironment
I want to convert the (IDocStreamData)hexbinary string like shown below to its equivalent character format which is a readable format.
IDocStreamData is of data type hexbinary in the defintion of SapGenericIDocObject.mxsd.
Here is the sample data:
<IDocStreamData>4544495f444334302020303130303030
I want output from say compute node like
OutputRoot.XMLNSC.data<EDI_DC40 010000>
Please let me know if I can provide more info on this. Thanks a lot |
|
Back to top |
|
 |
|