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 » using declare reference to

Post new topic  Reply to topic Goto page 1, 2  Next
 using declare reference to « View previous topic :: View next topic » 
Author Message
kwelch
PostPosted: Wed Jul 17, 2002 5:46 am    Post subject: using declare reference to Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi,

We are trying to use References to simplify our code but can't get them to work for our output. We have it working for the input. Below is the code we are using. Hopefully someone will spot something. We don't get any errors just a blank message. Thanks for any suggestions.

Karen

----CHECK TO DETERMINE IF THE OUTPUT SHOULD BE FORMATTED FOR AUTO OR PUP PKG
IF OutputLocalEnvironment.Variables.PUPIND = 'Y' THEN
SET OutputLocalEnvironment.Variables.C = OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq;
else
SET OutputLocalEnvironment.Variables.C = OutputRoot.XML.ACORD.InsuranceSvcRq.contact admin;
END IF;
DECLARE HDR1 REFERENCE TO OutputLocalEnvironment.Variables.C;

SET HDR1.RqUID = InputLocalEnvironment.Variables.InsuranceSvcRq.contact admin.RqUID;
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Wed Jul 17, 2002 7:48 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

Shouldn't it be InputRoot.XML.ACORD..... on right side? What is th compute mode for this Compute node? Are you copying Entire message or HEaders only in this compute node?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Wed Jul 17, 2002 8:38 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi Kiran,

We are copying headers only and using message and Local Environment from advanced tab. We want it to be OutputRoot. We are trying to do something similar to the example on p.24 of Neil Kolban's Using the new WMQI 2.1 ESQL features. Except for ours isn't a straight move we have to make a decision to decide what tag to use.

Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Wed Jul 17, 2002 9:09 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

I think Neil forgot to type-in one statemtnt on page 24.
CREATE FIELD OutputRoot.XML.Customer.Address;

In your code, you are trying to refer to OutputRoot.XML.ACORD...., please make sure these elements are created before you refer to them. If they don't exist, OutputLocalEnvironment.Variables.C will not be created. If you are getting ACORD as input XML message to this compute node, you should use InputRoot.XML.ACORD.... If you are creating a new message body in the same compute node, which I don't see in above ESQL, you could refer to them as OutputRoot.XML.ACORD...

Currently, OutputLocalEnvironment.Variables.C is not getting created so your reference is not working.

You are getting a blank message because you are not building any output message here. Either you should say "Copy Entire Message" in your compute node, or create message body in this compute node.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Wed Jul 17, 2002 11:08 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kirani,

When I code the CREATE FIELD OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq;
then I get the empty tag instead of a completely blank message.

We are just trying to shorten our code. Instead of coding:

SET OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq.RqUID = InputLocalEnvironment.Variables.InsuranceSvcRq.contact admin.RqUID;
Also the output tag changes depending on the indicator so we thought it would be a good way to not have to duplicate code. We would just up front check the indicator then set the reference variable to the appropriate one and use it. Something just isn't quite right! It looked so easy when I was reading the doc. and saw the example on p. 24!

Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Wed Jul 17, 2002 12:10 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

Using REFERENCE is really simple! Your ESQL code should look something similar to this,

Code:

CREATE FIELD OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq;
DECLARE HDR1 REFERENCE TO OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq;
IF InputLocalEnvironment.Variables.PUPIND = 'Y' THEN
SET HDR1 = OutputRoot.XML.ACORD.InsuranceSvcRq.PersPkgPolicyQuoteInqRq;
else
SET HDR1 = OutputRoot.XML.ACORD.InsuranceSvcRq.contact admin;
END IF;

_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Thu Jul 18, 2002 5:56 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi Kiran,

Thanks for the reply. I agree it should be simple. I copied your code exactly and ran it and got the following error

( HIGPLSBX1.PL_CDV_EXGRP ) Unable to perform copy. Element 'PersPkgPolicyQuoteInqRq' is a child of element 'PersPkgPolicyQuoteInqRq'. Additional diagnostic information is '235467472' '235467472'

A recursive copy was attempted but these are not allowed as they lead to indeterminate results. See earlier messages for details of the node in which this error occurred and the action taken as a result. is

Check the logic of the SQL of the node in which the error occurred


Any idea what the additional diagnostic information refers to?????
Is it possible this can't be done for output? We did get an example working for the input side of this.

Karen


Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu Jul 18, 2002 8:00 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

I am sure your input message format is not matching with my code.

I will try to give an example here explaining how to use REFERENCE for OutputRoot. I modified Neil's example a little bit to add Conditions in it. Depending on the data in Input XML message we will try to create output XML messages with different data using REFERENCE.

MQInput(xml)->Compute1->MQOutput

Compute Node (Copy Message Headers only):
Code:

CREATE FIELD OutputRoot.XML.Customer.Address;
DECLARE address REFERENCE TO OutputRoot.XML.Customer.Address;
IF (InputRoot.XML.Customer.Address.Code = 'S') THEN
  SET address.State = 'TEXAS';
  SET address.City = 'FORT WORTH';
  SET address.ZIP = 76180;
ELSE  IF( InputRoot.XML.Customer.Address.Code = 'SW') THEN
    SET address.State = 'CALIFORNIA';
    SET address.City = 'TORRANE';
    SET address.ZIP = 90503;
  END IF;
END IF;



Input Msg 1:
<Customer><Address><Code>S</Code></Address></Customer>

Output:
<Customer><Address><State>TEXAS</State><City>FORT WORTH</City><ZIP>76180</ZIP></Address></Customer>

Input Msg 2:
<Customer><Address><Code>SW</Code></Address></Customer>

Output:
<Customer><Address><State>CALIFORNIA</State><City>TORRANE</City><ZIP>90503</ZIP></Address></Customer>


Based on this example, you could modify your code in Compute node to use REFERENCE to OutputRoot.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Thu Jul 18, 2002 10:11 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi Kiran,

Thanks for all the help you have provided. I copied your sample XML code and it worked. And BTW your other code did match our data. The problem seems to be when we try to SET the reference to a new value, that we get the recursive error I posted below. That's the only difference in the code.

We want to change the tag based on that indicator. For example using your sample: We would like for when InputRoot.XML.Customer.Address.Code = 'S' the Output tag be
OutputRoot.XML.Customer.Address but when it is 'SW' we want it to be
OutputRoot.XML.Customer.SWAddress.

So for the S cases the output would look like this:

<Customer><Address><State>TEXAS</State><City>FORT WORTH</City><ZIP>76180</ZIP></Address></Customer>

and for the SW cases like this:

<Customer><SWAddress><State>CALIFORNIA</State><City>TORRANE</City><ZIP>90503</ZIP></SWAddress></Customer>


Maybe that is not possible?


Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu Jul 18, 2002 10:34 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

This is also possible by creating a reference to OutputRoot.XML.Customer. So if you modify the code to:

Code:

CREATE FIELD OutputRoot.XML.Customer;
DECLARE address REFERENCE TO OutputRoot.XML.Customer;

IF (InputRoot.XML.Customer.Address.Code = 'S') THEN
  SET address.Address.State = 'TEXAS';
  SET address.Address.City = 'FORT WORTH';
  SET address.Address.ZIP = 76180;
ELSE  IF( InputRoot.XML.Customer.Address.Code = 'SW') THEN
    SET address.SWAddress.State = 'CALIFORNIA';
    SET address.SWAddress.City = 'TORRANE';
    SET address.SWAddress.ZIP = 90503;
  END IF;
END IF;


It will work!

The basic rule for using REFERENCE is:
"You cannot REFERENCE to something, which doesn't exist!!"

This is the reason we are using CREATE FIELD first in our code.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Thu Jul 18, 2002 10:47 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kiran,

Thanks again for your endurance and patience with this. I agree with what you just said, however, this kind of defeats the purpose for us. We were trying to get away from having to code all the statements twice just because of a few characters difference in one of the tag names!
In your case it's not big deal. You only have 3 fields. We have 1000's. We were hoping we could set the tag depending on the indicator then just have one set of assignments. Based on what I am seeing this won't work??

Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu Jul 18, 2002 12:11 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

So what I understand is, you are trying to create an output message from input message with different TAGNames. these TagNames are decided based on some condition. correct?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Thu Jul 18, 2002 12:15 pm    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kiran,

Yes. I apologize for not making that clearer up front.

Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu Jul 18, 2002 12:35 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

great!
So, let's modify my code to create TAGNAME based on some condition.

Code:

CREATE FIELD OutputRoot.XML;
DECLARE address REFERENCE TO OutputRoot.XML.Customer;

IF (InputRoot.XML.Customer.Code = 'S') THEN
  CREATE FIELD address.Address;
ELSE
  CREATE FIELD address.SWAddress;
END IF;

MOVE address FIRSTCHILD;

SET address.State = InputRoot.XML.Customer.Address.State;
SET address.City = InputRoot.XML.Customer.Address.City;
SET address.ZIP = InputRoot.XML.Customer.Address.ZIP;



In above code, we are typing SET command only once. Will this work for you?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Thu Jul 18, 2002 5:21 pm    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kiran,

I don't know! I will cross my fingers! I was under the impression, from a prior thread, on the same subject, that if you declared something within an IF or a WHILE that you could only use it within those confines? That's why in my very first post here we were trying to store things in the OutputLocalEnvironment.

I am out of the office tomorrow and won't be able to try this until Monday. Thanks and have a great weekend! I will let you know on Monday.

Karen
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » using declare reference to
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.