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 » Passing reference variable as INOUT to the java procedure

Post new topic  Reply to topic
 Passing reference variable as INOUT to the java procedure « View previous topic :: View next topic » 
Author Message
Mercury
PostPosted: Mon Dec 11, 2006 5:59 am    Post subject: Passing reference variable as INOUT to the java procedure Reply with quote

Apprentice

Joined: 24 Jun 2006
Posts: 32
Location: Hyderabad

Hi MBIANS,
I am trying to pass a reference variable to the Java procedure.My requirement is -- java function should modify the reference variable

Here is my code
CALL CopyMessageHeaders();
CREATE FIELD OutputRoot.XML.Data.Result;
SET OutputRoot.XML.Data.Result[] = LIST{InputRoot.XML.Car.colour,'green','BLUE','red','GREEN'};
DECLARE myVar CHAR 'dummy';
DECLARE myRef REFERENCE TO OutputRoot.XML.Data;
CALL testArray(myVar,myRef.Result[]);
---
Here is my fn call
CREATE FUNCTION testArray (IN var CHAR, INOUT myArray REFERENCE)
LANGUAGE JAVA
EXTERNAL NAME "com.xyz.MyUtil.test";
--------
Here is my java fn
public static void test(String var, MbElement[] actual){
--setting pointer
MbElement dum = actual[0];
try{
int i=1;
while (dum != null){
dum.setValue("abc" + i);
if (i>2)
dum.detach();
i++;
dum= dum.getNextSibling();
}
actual[0] = dum;
}catch (Exception e){
/*---------------*/
}
}
Expected o/p for this is SET OutputRoot.XML.Data.Result[] should have caridnality 2 with list members abc1 and abc2. But it contains abc1,abc2,red,GREEN
Can any one please find out where I am going wrong in java fn

thanks in advance
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jefflowrey
PostPosted: Mon Dec 11, 2006 6:19 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Your Java procedure does many things that you don't want it to do.

In particular, you're looping until dum == null, and then assiging actual to dum.

You're also getting the next sibling of dum after you've detached it.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Mercury
PostPosted: Mon Dec 11, 2006 6:30 am    Post subject: Reply with quote

Apprentice

Joined: 24 Jun 2006
Posts: 32
Location: Hyderabad

thanks for the reply jefflowrey
my Idea was storing the modified list in the dum and copying again into actual.Since modifying the INOUT reference parameter directly doesn't give the modified list to the function. So I did like this
What do u suggest ?
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jefflowrey
PostPosted: Mon Dec 11, 2006 6:34 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I'd suggest you write the procedure in ESQL until you get it working, and then convert the ESQL to java.
_________________
I am *not* the model of the modern major general.
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 » Passing reference variable as INOUT to the java procedure
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.