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 » Convert a Character to Reference issue

Post new topic  Reply to topic
 Convert a Character to Reference issue « View previous topic :: View next topic » 
Author Message
yaemu
PostPosted: Tue Mar 29, 2011 4:57 am    Post subject: Convert a Character to Reference issue Reply with quote

Novice

Joined: 27 Oct 2010
Posts: 17

Hi,

I have a UDP variable and its data type is CHARACTER,
the value of the UDP will be a path of an element in the message tree, for example:
'InputRoot.XMLNSC.MSG.Body.elem'

I need to assign this value to variable of a reference data type,

because I need to access message element

the Cast function does not convert to a reference Data type.

Do you have any idea how to convert it?

Thanks,
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Tue Mar 29, 2011 5:23 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Quote:
A field reference consists of a correlation name followed by zero or more path elements separated by periods.


This is why cast would not work.

Why not try hard coding an example within the Compute node. When you figure out the combination that works, transfer that info to the UDP. You may need to use two UDPs.

I'm not an "ex-pert" on ESQL, just a "pert". mqjeff or vitor may know some other things that could help here.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
paintpot
PostPosted: Tue Mar 29, 2011 6:34 am    Post subject: Reply with quote

Centurion

Joined: 19 Sep 2005
Posts: 112
Location: UK

If I understand your question, it is how to access part of the message tree based on a variable, which you have as a UDP.

Use curly braces.

Code:

SET OutputRoot.XMLNSC.{UDP_testvar}.restOfTree = "blah";


etc
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Mar 29, 2011 7:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Curly braces only evaluate a single level. So OutputRoot.XMLNSC.Body.{fieldName} will work if fieldName = 'UserValue' but not if it = "user.value".

You can use EVAL.
Back to top
View user's profile Send private message
paintpot
PostPosted: Tue Mar 29, 2011 8:23 am    Post subject: Reply with quote

Centurion

Joined: 19 Sep 2005
Posts: 112
Location: UK

I want to be mqjeff when I grow up
Back to top
View user's profile Send private message
gechu
PostPosted: Sun May 22, 2011 11:12 pm    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

Hi, I´m not very comfortable with EVAL yet, can you give me a hint about how to use it when creating a reference where the trailing field identifier contains dots. Here is my example. I´ve added "" around the string with dots:

Code:
DECLARE myRef REFERENCE TO InputLocalEnvironment.Variables.config.{messageRef.msgType}.{messageRef.distributorId}.{messageRef.recordType}."Destination.FTP.user";
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon May 23, 2011 12:52 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

EVAL uses a lot of CPU. You could achieve the same result by splitting up the string using POSITION and SUBSTRING. Loop until POSITION('.' IN trailingFieldIdentifier REPEAT N) returns zero. Each time around the loop, increment N and MOVE myREF FIRSTCHILD Name thisFieldName.

...and don't forget to check LASTMOVE after every MOVE.
Back to top
View user's profile Send private message
gechu
PostPosted: Mon May 23, 2011 2:54 am    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

Thanks Kimbert for the reply. Haven´t tried it in code yet, but I get the basic idea.

You wrote that EVAL used a lot of CPU. I was planning to use EVAL to dynamically call a function like this myGenericFunction(anyParam1, anyParam2, dynamicFunction);

in dynamicFunction I would store in a string the name of the function that I wanted to call.

Should I avoid using EVAL or are there better ways to handle dynamic function calling?
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon May 23, 2011 3:32 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Should I avoid using EVAL
No, not necessarily. It depends on whether your message flow needs to keep its CPU usage to a minimum. Sometimes a solution that uses EVAL is the simplest and best.

MGK may have some detail to add to this...
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon May 23, 2011 4:55 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

With eval, you would have something like
Code:
DECLARE myRef REFERENCE TO EVAL('InputLocalEnvironment.Variables.config.'||messageRef.msgType||'.'||messageRef.distributorId||'.'||messageRef.recordType||'.'||Destination.FTP.user);
Back to top
View user's profile Send private message
gechu
PostPosted: Mon May 23, 2011 6:01 am    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

Thanks a lot!
Back to top
View user's profile Send private message
gechu
PostPosted: Tue May 24, 2011 10:54 pm    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

Just when I thought I was out they [read ESQL] dragged me back in!!

My problem description wasn´t accurat because I didn´t understand the actual problem.

Here it is, I think, in plain text what I want to do. But it doesn't work:

Code:

DECLARE TargetRef REFERENCE TO InputLocalEnvironment.Variables.config;
         
DECLARE TargetStr CHARACTER messageRef.oneID || '.' || messageRef.anotherID || '.' || 'Destination.FTP.userName';
-- resolves to string: myID.anotherID.Destination.FTP.userName,, a field with exacly that name exists as a child to where TargetRef points.

-- try to move my reference to the desired field:
MOVE Vidb_TargetRef FIRSTCHILD NAME Vidb_TargetStr;


What am I doing wrong?
Back to top
View user's profile Send private message
gechu
PostPosted: Wed May 25, 2011 1:08 am    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

strangely, if I hardcode the string like this


Code:
MOVE Vidb_TargetRef FIRSTCHILD NAME 'myID.anotherID.Destination.FTP.userName'



it works..
Back to top
View user's profile Send private message
gechu
PostPosted: Wed May 25, 2011 2:03 am    Post subject: Reply with quote

Apprentice

Joined: 27 Feb 2008
Posts: 48

stupid typo. Problem solved.
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 » Convert a Character to Reference issue
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.