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 » ESQL Procedures

Post new topic  Reply to topic
 ESQL Procedures « View previous topic :: View next topic » 
Author Message
apsy
PostPosted: Mon Aug 02, 2004 4:07 pm    Post subject: ESQL Procedures Reply with quote

Novice

Joined: 10 Feb 2004
Posts: 24

I need to accomplish the following.
1. Create a re-usable procedure that will create a new output root and send it back
Requirements: I want to create a brand new XML message in a procedure, that is returned back to the caller.
So far, I have achieved the following piece of code and it works:

/********************/

DECLARE rOutRefXml REFERENCE TO OutputLocalEnvironment;
DECLARE rInRefXml REFERENCE TO InputLocalEnvironment;
MOVE rInRefXml TO InputRoot.XML;

--Build the XML Decleration
CREATE FIELD OutputRoot.XML.(XML.XmlDecl)XML;
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding") = 'UTF-8';
CREATE LASTCHILD of OutputRoot.XML AS rOutRefXml NAME 'CompanyNew';


--This procedure is created in a separate ESQL file:

--Call this procedure to build the output xml
CALL ProcAddFields(rInRefXml,rOutRefXml);

I get an output root that I then successfully send to an MQ output node.

/********************/




/**********/
Procedure that creates a brand new XMl mesage and returns back to caller
/********** Define procedure in new ESQl file ************/

BROKER SCHEMA LIB_Common

-- This procedure builds output xml from input xml and returns a xml tree
CREATE PROCEDURE ProcAddFields(IN rInRefXml REFERENCE,INOUT rOutRefXml REFERENCE)
BEGIN

SET rOutRefXml.Empid = '2374521';
SET rOutRefXml.LastName = 'Sam';

RETURN;
END;

/********End procedure *******?


3) I tried moving everyting within the procedure by passing in the output oot directly to my procedure and manipulating it., I got an o/p message forwarded to my queue, but the length was zero.

4) What I want to do is, move even the XML declaration (in bold above) into the procedure. That way , the caller does not have to do anything. Anytime he needs an o/p message of that structure, he just calls the procedure, which accomplishes everything. I want the caller to be oblivious to what is being returned back. All the caller should do is to forward the message to a queue.Is this possible?

The reason I want to do this is, the procedure is something that all my flows across message flow projects and within message flows will use it multiple times, and I want to avoid code redundancy.


Sample test i/p message

<?xml version = "1.0" encoding = "UTF-8"?>
<CrCard>
<company>Test</company>
<DeptNo>1001</DeptNo>
</CrCard>

Sample test o/p message

<?xml version="1.0" encoding="UTF-8"?>
<CompanyNew>
<Empid>2374521</Empid>
<LastName>Sam</LastName>
</CompanyNew>
Back to top
View user's profile Send private message
CoolDude
PostPosted: Mon Aug 02, 2004 5:45 pm    Post subject: Reply with quote

Apprentice

Joined: 17 Jan 2004
Posts: 39

Please check the Reference variable. you have declared the reference variable to an OutputLocalEnvironment. Is should be declared as reference to some Output Tree.


Code:
DECLARE rOutRefXml REFERENCE TO OutputLocalEnvironment;



Consider the below example.

Note : I am using the same Input message that you have specified.

CREATE FIELD OutputRoot.XML.Employee;
DECLARE rOutRefXml REFERENCE TO OutputRoot.XML.Employee;
DECLARE rInRefXml REFERENCE TO InputRoot.XML.CrCard;

Call cOuputXML(rInRefXml, rOutRefXml);


CREATE PROCEDURE cOuputXML(IN rInRefXml REFERENCE,INOUT rOutRefXml REFERENCE)
BEGIN

SET rOutRefXml.Empid = rInRefXml.DeptNo;
SET rOutRefXml.LastName = rInRefXml.company;

RETURN;
END;

This would create

<Employee>
<Empid>1001</Empid>
<LastName>Test</LastName>
</Employee>

Thanks
_________________
Correct Me from Wrong . If i am correct Appreciate Me
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Tue Aug 03, 2004 1:45 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Hi,
You can also refer to messagebroker_esql.pdf for constructing and manipulating XML Messages. It is really helpful.
I have done such transforms as SWIFT Message to application specific accounting mesage (both in XML) using these manipulation technique.
I am not very sure, but you can always pass the reference variable to the common procedure and see what will happen.
But what CoolDude says is true. You have to declare the reference variable to refer to your Input/Output Roots rather than LocalEnvironments.
The useful technique is, retain the original XML Message in some temp folder as part of your outputroot tree, and delete it when you finish your transformation.
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
apsy
PostPosted: Tue Aug 03, 2004 5:18 am    Post subject: Reply with quote

Novice

Joined: 10 Feb 2004
Posts: 24

Basically, the XML message that I am constructing within a procedure is actualy used for logging purposes and is independent of the message data (xml, fixed length , etc,etc)coming in .
so my requirement is that I always construct an XML message . The challenge I am facing is that I want the entire Output root to be constructed and returned from within the procedure. I do not want to manipulte an incoming message. I am not able to do that compactly within my procedure, because my XMl declaration statements do not seem to work if I move them inside my procedure.
Back to top
View user's profile Send private message
mgk
PostPosted: Tue Aug 03, 2004 5:59 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

If you search this forum you should find a post from me decribing the difference between OutputRoot and a Reference to OutputRoot.

However as you are using version 5 of the brokers, you should know that the root Correlation Names (OutputRoot etc) are now effectively Implicitly Declared Module Level Variables. This means that you can use them in functions and procedures that are written at module (but not schema) scope without having to pass them in as a reference.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
apsy
PostPosted: Tue Aug 03, 2004 10:34 am    Post subject: Reply with quote

Novice

Joined: 10 Feb 2004
Posts: 24

Thanks a lot mgk !!!!. I found ur earlier post. Gave me exactly what I was looking for.


-Apsy
Back to top
View user's profile Send private message
javaforvivek
PostPosted: Wed Aug 04, 2004 12:09 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

Hi mgk,

Can you give the link to that post??

Thx in advance
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mgk
PostPosted: Wed Aug 04, 2004 1:57 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

May I respectfully suggest that you do what the previous posted did and search the forum yourself.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
apsy
PostPosted: Wed Aug 04, 2004 11:39 am    Post subject: Reply with quote

Novice

Joined: 10 Feb 2004
Posts: 24

Vivek ,
Search for a post and by authored by "mgk"

and then lookfor the title

"Message Headers not getting copied to output"
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 » ESQL Procedures
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.