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 » Understanding Trim Function

Post new topic  Reply to topic
 Understanding Trim Function « View previous topic :: View next topic » 
Author Message
mpong
PostPosted: Thu Nov 07, 2013 3:44 am    Post subject: Understanding Trim Function Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

Hi All,


I am using Data pattern to receive below msg.
"text1" "text2" "text3"

After i receive each element in compute node, i want to trim leading and trailing double quotation marks so i used the below code and it works but i don't understand how exactly it works.


SET Text = TRIM('"' FROM (InputRoot.MRM.text1)); it trims only on the left side not both side.
Result : Text = text1"

but when i use trim function twice i get the result as expected
SET Text = TRIM('"' FROM TRIM(InputRoot.MRM.text1));
Result : Text = text1


Can you pls explain me, I dont understand how exactly the inner trim function helps.

EDIT by exerk: Moving this to the Broker forum.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 07, 2013 3:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You shouldn't be using Data Patterns for this.

You shouldn't be using MRM for this.

You're trying to parse a CSV file the hard way.

Go back to the product samples and your training material and start over.

If you're on WMB v8 or 9 use the DFDL parser and use the predefined models for CSV files. If you're not on v8 or v9, use the MRM samples for CSV files.

The TRIM function does exactly what it's documented to do.
The TRANSLATE function does exactly what it's documented to do.

They are different functions.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Thu Nov 07, 2013 4:16 am    Post subject: Re: Understanding Trim Function Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

I don't think this can work:
mpong wrote:

SET Text = TRIM('"' FROM TRIM(InputRoot.MRM.text1));

As the inner TRIM would trim the default character, i.e. spaces and not the double quotes as you claim. So your code is suspect.

Or, your InputRoot.MRM.text1 is in fact '"text1" ', i.e you are receiving the string "text1" followed by a space. In wich case only one TRIM will not work, as the " is followed by a space. In that case, the inner trim is removing the spaces at the end, and then the next trim removes the double quotes.
Whichever way, if you run a user trace and read it, you will find what the problem is and will help you to understand the Trim function
Back to top
View user's profile Send private message
mpong
PostPosted: Thu Nov 07, 2013 10:09 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

Hi,

This is not a CSV file, input from the source file is as below:

"aaaaaaa" "bbbbb" "cccccc" "dddd"
and I use MRM message set using the data patteren "[^"]*" to fetch each element and it works fine.

SET Element1 = TRIM('"' FROM TRIM(InputRoot.MRM.text1)); also gives me the correct output.
Back to top
View user's profile Send private message
Esa
PostPosted: Thu Nov 07, 2013 10:41 pm    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

mpong wrote:

This is not a CSV file, input from the source file is as below:

"aaaaaaa" "bbbbb" "cccccc" "dddd"
and I use MRM message set using the data patteren "[^"]*" to fetch each element and it works fine.

SET Element1 = TRIM('"' FROM TRIM(InputRoot.MRM.text1)); also gives me the correct output.


Yes, because text1 contains '"aaaaaaa" '.

now I see that dogorsy already told you that.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri Nov 08, 2013 12:04 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

mpong wrote:


SET Element1 = TRIM('"' FROM TRIM(InputRoot.MRM.text1)); also gives me the correct output.

I have already explained why, and also suggested you get a user trace, look at it and understand the TRIM function.
Back to top
View user's profile Send private message
mpong
PostPosted: Fri Nov 08, 2013 4:12 am    Post subject: Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

Hi dogorsy, got it thanks
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Nov 08, 2013 8:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

mpong wrote:
Hi,

This is not a CSV file, input from the source file is as below:

"aaaaaaa" "bbbbb" "cccccc" "dddd"
and I use MRM message set using the data patteren "[^"]*" to fetch each element and it works fine.

SET Element1 = TRIM('"' FROM TRIM(InputRoot.MRM.text1)); also gives me the correct output.


Yes, it is a CSV file.

It's just the "C" is actually a "space", not a "comma".

The sooner you accept that, the sooner you will stop using data patterns and start improving the format of your flow.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Understanding Trim Function
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.