Author |
Message
|
umesh |
Posted: Fri May 13, 2005 1:22 am Post subject: Simple flow in WBIMB |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
Hi all,
I have a small message flow requirement to be done in WBIMB 5.
1. I have to take data from Input Queue (in TDS format) and I have a database where codes are stored in a DB2 table .
2.I have to query(SQL SELECT) all these codes stored in table .
3. Then I have to add a value called IN.1(which are queue names for different codes) to end of each of these codes retrieved from database.Then the message is to be put into these different queues.
Say for example I have retrieved A and B from database I have to make A.IN.1 and B.IN.1 .These are local queues where final TDS message has to be put.
Please help me to solve this problem. I am new to WBIMB 5.
thanks
umesh |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri May 13, 2005 3:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I don't see a problem.
You merely need to build a message set and a message flow to accomplish the tasks before you.
Your message flow will be built like any other program, using different nodes and ESQL.
Pretend you had to write this in Java. Write down the steps you need to perform, and match each one to a different node. Then use ESQL to fill in the decisions you need to make. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
umesh |
Posted: Tue May 17, 2005 7:54 pm Post subject: ESQL result in flow |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
Hi,
Thanks for the reply. I have built a message set and currently building message flow.I am using compute node to retrieve data using ESQL.I am writing a query to retrieve codes (single column)which always fetches multiple results since there are more than one code.
But my doubt is how to include the result from query in my message flow. Now after fetching result say there are 10 entries,
I have to loop ten times to append code1.OUT.1 , code2.OUT.1 etc which is output queue name for each code.The message has to be finally put into this queue.
thanks,
unesh |
|
Back to top |
|
 |
fschofer |
Posted: Wed May 18, 2005 1:56 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
|
Back to top |
|
 |
umesh |
Posted: Wed May 18, 2005 8:09 pm Post subject: Simpe flow in WBIMB |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
hi,
thanks for the reply. I have gone through links provided and found them useful .Now Since I have just started on WBIMB I am asking few basic questions. Request you to pl guide me.
There is an input in the form of TDS which has around 15 fields out of which one field is this code. To set this code I have to retrieve all codes available in a database table and then assign other data elements (in a loop since tehre are multiple codes)and finally put it into a queue by appending code with OUT.1 like cd01.OUT.1 which is an output queue.Say for example I have retrieved A and B from database I have to make A.OUT.1 and B.OUT.1 .These are local queues where final TDS message has to be put.
so how to include the result from query in my message flow ,loop and append?
Request you to provide more details. The code i am trying is attached below which is in compute node.
DECLARE count INTEGER
SET OutputRoot.XML=InputRoot;
SET Result[]=(SELECT T.CD FROM Database.CODES as T);
count=CARDINALITY(OutputRoot.XML.Test.Result[]);
IF CARDINALITY(OutputRoot.XML.Test.Result[])> 0 THEN
DECLARE i INTEGER;
SET i=1;
WHILE (i<count)
OutputRoot.XML.Test.Result[i]= OutputRoot.XML.Test.Result[i] || 'OUT.1'
SET i=i+1;
END WHILE;
END IF;
RETURN TRUE;
thanks
umesh |
|
Back to top |
|
 |
JT |
Posted: Thu May 19, 2005 8:58 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
The following statement was a little confusing to me:
Quote: |
There is an input in the form of TDS which has around 15 fields out of which one field is this code. To set this code I have to retrieve all codes available in a database table and then assign other data elements (in a loop since tehre are multiple codes)and finally put it into a queue by appending code with OUT.1 like cd01.OUT.1 which is an output queue.Say for example I have retrieved A and B from database I have to make A.OUT.1 and B.OUT.1 .These are local queues where final TDS message has to be put.
|
This implies a single code is to be added to the output TDS message, but the SELECT call can retrieve multiple values. (??) Regardless, this sample should provide you a place to start:
Code: |
CALL CopyEntireMessage();
SET Environment.Variables.Result = (SELECT T.CD FROM Database.CODES as T);
DECLARE i INTEGER 1;
FOR result AS Environment.Variables.Result[] DO
SET OutputLocalEnvironment.Destination.MQ.DestinationData[i].queueName = result.CD || '.OUT.1';
-- If need be, you can add the database CD element to the output TDS message here:
-- SET OutputRoot.MRM.Test.Result[i].CD = result.CD;
SET i = i + 1;
END FOR;
RETURN TRUE; |
You'll also need to set the 'Destination Mode' of the MQOuput node to DestinationList. |
|
Back to top |
|
 |
umesh |
Posted: Fri May 20, 2005 12:44 am Post subject: |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
Hi,
Thanks for the reply. You are right in saying that select code would always return multiple values but single code to be added to code field of message field and this shall be done in a loop so that we can include all values retrieved in a loop.
In your code you have written
SET Environment.Variables.Result = (SELECT T.DEALER_CD FROM Database.CODES as T); where Result shall hold multiple values .So whether this has to be made Result[] to include multiple values?
I missed a point here. After framing proper TDS message it has to be put into respective queues obtained by concatenating code with OUT.1 (ex A.OUT.1 ,B.OUT.1, C.OUT.1 where A,B,C are obtained by querying database table) .So Do i need to use PROPAGATE statement inside loop so that 10 messages are put into 10 diff queues?
One more additional thing is what if I have to retrieve another column say NAME and add it to one of field in message.
How Do I access the value retrieved from database and use it into ESQL code (since the query changes to SELECT T.CD,T.NAME FROM Database.CODES) as T I have a slight confusion in code since result and Result are used?
thanks.
umesh
CODE:
SET Environment.Variables.Result[] = (SELECT T.CD ,T.NAME FROM Database.CODES as T);
DECLARE i INTEGER;
SET i=1;
FOR result AS Environment.Variables.Result[] DO
SET OutputLocalEnvironment.Destination.MQ.DestinationData[i].queueName= result.Code || '.OUT.1' ;
SET OutputRoot.MRM.Details.Result[i].CD=result.CD;
SET OutputRoot.MRM.Details.Result[i].NAME=result.NAME;
PROPAGATE;
SET i=i+1;
END FOR;
RETURN TRUE; |
|
Back to top |
|
 |
fschofer |
Posted: Fri May 20, 2005 1:44 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Hi,
after calling PROPAGATE the output message trees are cleared
so you have to rebuild them each time.
Try this:
Code: |
SET Environment.Variables.Result[] = (SELECT T.CD ,T.NAME FROM Database.CODES as T);
FOR xyz AS Environment.Variables.Result[] DO
SET OutputRoot.Properties = InputRoot.Properties;
SET OutputRoot.MQMD = InputRoot.MQMD;
SET OutputRoot.MRM.Details.Result.CD=xyz.CD;
SET OutputRoot.MRM.Details.Result.NAME=xyz.NAME;
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName= xyz.CD || '.OUT.1' ;
PROPAGATE;
END FOR;
RETURN TRUE; |
Greetings
Frank |
|
Back to top |
|
 |
umesh |
Posted: Fri May 20, 2005 3:59 am Post subject: Simple message flow |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
Hi,
Thanks for the reply. But need some more clarity. Whether I=I+1 is not required in code? Whether my way of accessing variables in variables is correct? Here Details stands for my message type in message set definition.
Also whether Result[] is ok to get all codes, names list from database?
Thanks,
umesh |
|
Back to top |
|
 |
umesh |
Posted: Sun May 22, 2005 8:48 pm Post subject: |
|
|
Novice
Joined: 13 May 2005 Posts: 16
|
Hi,
with all your inputs ,Now I am able to retrieve values but it is giving Parser exception message "No message Id received".I am giving TDS message as input in the form of a+...... where + is seperator.I have checked project reference properties and message set definitions.
thnaks,
umesh |
|
Back to top |
|
 |
|