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 » How to add an String to the Output Message

Post new topic  Reply to topic
 How to add an String to the Output Message « View previous topic :: View next topic » 
Author Message
pbravi
PostPosted: Thu May 23, 2002 3:54 am    Post subject: How to add an String to the Output Message Reply with quote

Newbie

Joined: 15 May 2002
Posts: 6
Location: INDIA

Hi All
We want to remove an string from the input message, process and convert the message to XML and again append the same string to the output message as a prefix

The scenario is as follows
Input Message
100#URG+ME001+EDI

1)We want to remove the 100# and parse the rest of message and tranform to XML.

we are able to achive the Point 1
Our output is
<URGSEGMENT>
<Messagecode>ME001</Messagecode>
<Messageformat>EDI</Messageformat>
</URGSEGMENT>

Required Output
----------------------
We want to append the removed string to the output for further processing
100#
<URGSEGMENT>
<Messagecode>ME001</Messagecode>
<Messageformat>EDI</Messageformat>
</URGSEGMENT>

The Method we are following is
First we are parsing the blob message and by casting it to string we are removing the 100# again converting the message as blob and sending it to the ResetNode. Here the blob gets parsed according to the message type.

How to prefix the removed string 100# again to the processed XML message

Thanks in Advance
P.B.Ravichandran
Back to top
View user's profile Send private message MSN Messenger
Ward
PostPosted: Thu May 23, 2002 4:20 am    Post subject: Reply with quote

Voyager

Joined: 27 Jun 2001
Posts: 98
Location: Europe

Hi,

By adding the string in front of your XML message the message is not valid XML anymore. To avoid parsing problems you will have to first convert it to BLOB using a ResetContentDescriptor node.

Next problem you face is that you're looking at hex values now. If the string could be anything you won't be able to like hard code a set of hex values to add. What I would suggest then is add the string into your XML first with some known tags. Once you're converted to BLOB all you have to do is SUBSTRING the tags out of your string. Your begin tag will always be at the very beginning. You'll find the end tag by doing a POSITION lookup for a know series of hex-values.

Be careful though as the XML to BLOB will leave you with things like &apos; instead of the real apostrophe etc... If that's a problem you'll have to search for those strings and replace them...

Enjoy

Ward.
_________________
IBM Certified Solution Designer -- WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
----------------------------
Visit Boat Dimensions
Back to top
View user's profile Send private message Send e-mail Visit poster's website
granthmuk
PostPosted: Thu May 23, 2002 4:26 am    Post subject: Reply with quote

Apprentice

Joined: 16 May 2001
Posts: 38
Location: Edinburgh, Scotland

Not sure what your exact requirement is but the example you illustrate with the 100# preceding the XML structure would not be valid XML. You could use the RFH2 header to store this value
Code:

SET OutputRoot.MQRFH2.usr.myVariable=THEVALUE;

or store it somewhere within the body of your XML e.g.

Code:

SET OutputRoot.XML.myRoot=THEVALUE;
SET OutputRoot.XML.URGSEGMENT=OTHERVALUE;
etc.


<myRoot>
100#
<URGSEGMENT>
....
</URGSEGMENT>
</myRoot>
Back to top
View user's profile Send private message
pbravi
PostPosted: Thu May 23, 2002 5:49 am    Post subject: Reply with quote

Newbie

Joined: 15 May 2002
Posts: 6
Location: INDIA

hi all
we are very well aware that my xml won't be valid with 100#, but its a business need we will remove that string before parsing it to the xml parser.

we want add the string to the existing xml output.


Thanks and Regards
P.B.Ravichandran
Back to top
View user's profile Send private message MSN Messenger
Ward
PostPosted: Thu May 23, 2002 6:01 am    Post subject: Reply with quote

Voyager

Joined: 27 Jun 2001
Posts: 98
Location: Europe

Well, that leaves you with my solution mentioned above... Here's some code you can use given you created first the xml statement like this:

<TMP>
100#
<URGSEGMENT>
<Messagecode>ME001</Messagecode>
<Messageformat>EDI</Messageformat>
</URGSEGMENT>
</TMP>


DECLARE STATEMENT CHARACTER ;
DECLARE BLOBSTATEMENT BLOB ;
DECLARE POS INTEGER ;

SET BLOBSTATEMENT = SUBSTRING( InputRoot."BLOB"."BLOB" FROM 6 FOR LENGTH( InputRoot."BLOB"."BLOB" ) - 11 ) ;
SET STATEMENT = CAST ( BLOBSTATEMENT AS CHAR ) ;

-- replace &apos; by '
SET POS = POSITION ( '2661706f733b' IN STATEMENT ) ;
WHILE ( POS > 1 ) DO
SET STATEMENT = SUBSTRING( STATEMENT FROM 1 FOR (POS - 1)) || '27' ||
SUBSTRING( STATEMENT FROM (POS + 12) FOR (LENGTH(STATEMENT) - POS - 11)) ;
SET POS = POSITION ( '2661706f733b' IN STATEMENT ) ;
END WHILE ;

SET OutputRoot."BLOB"."BLOB" = CAST( STATEMENT AS BLOB ) ;

Cheers,

Ward.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ward
PostPosted: Thu May 23, 2002 6:15 am    Post subject: Reply with quote

Voyager

Joined: 27 Jun 2001
Posts: 98
Location: Europe

if you're going to parse the xml part then you probably don't want the replacing of the &apos;

Ward
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pbravi
PostPosted: Sat May 25, 2002 1:35 am    Post subject: Reply with quote

Newbie

Joined: 15 May 2002
Posts: 6
Location: INDIA

Thanks
It was working, we stored the remove 100# in a variable and concanitaded it to the output after converting it to blob(thru reset node)

Appendstr = cast(InputRoot.MQRFH2.usr.myvariable as BLOB);
SET Outputroot."BLOB"."BLOB" = Appendstr || Inputroot."BLOB"."BLOB";


Thanks and Regards
P.B.Ravichandran
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to add an String to the Output Message
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.