Author |
Message
|
mahek |
Posted: Tue Mar 01, 2005 2:12 pm Post subject: USING PROPAGATE |
|
|
Voyager
Joined: 10 Sep 2004 Posts: 87
|
Hi all,
I Have the following problem
I HAVE THE INPUT SUPPOSE AS
[1,2]
[2,4]
[1,6]
[2,9]
[1,8]
THE group indicator is [ and terminator is ] AND REPEATING ELEMENTS DELEMITED BY <CR><LF>
I am having a message set in which DETAILS is the repeating element having FIRSTNAME AND LASTNAME AS ITS INNER ELEMENTS.
I have to get the output as
ON QUEUE A
1,2
1,6
1,8
AS ONE MESSAGE
AND ONE QUEUE B
<MESSAGE>
<N>
<FN>2</FN>
<LN>4</LN>
</N>
<N>
<FN>2</FN>
<LN>9</LN>
</N>
</MESSAGE>
I HAVE THE FOLLOWING CODE FOR THIS
CREATE COMPUTE MODULE FLOATMF_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE K INTEGER 1;
DECLARE L INTEGER CARDINALITY(InputRoot.MRM.DETAILS[]);
WHILE K <= L DO
CALL CopyMessageHeaders();
IF InputRoot.MRM.DETAILS[K].FN='1'
THEN
SET OutputRoot.Properties.MessageSet = 'EBQDKJC002001';
SET OutputRoot.Properties.MessageType = 'FLOATMSG1';
SET OutputRoot.MRM.DETAILS[K].FIRSTNAME =InputRoot.MRM.DETAILS[K].FN;
SET OutputRoot.MRM.DETAILS[K].LASTNAME= InputRoot.MRM.DETAILS[K].LN;
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName = 'A';
SETOutputLocalEnvironment.Destination.MQ.DestinationData.queueManagerName ='BMB';
ELSE
SET OutputRoot.XML.MESSAGE.N[K].FN=InputRoot.MRM.DETAILS[K].FN;
SET OutputRoot.XML.MESSAGE.N[K].LN=InputRoot.MRM.DETAILS[K].LN;
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName 'B;
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueManagerName= 'BMB';
END IF;
SET K=K+1;
PROPAGATE;
END WHILE;
RETURN FALSE;
END;
Can any one tell me what mistake i am doing.
Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 01, 2005 2:23 pm Post subject: Re: USING PROPAGATE |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
mahek wrote: |
Can any one tell me what mistake i am doing.
Thanks |
Can you tell us what it is doing that you think is wrong?
Can you tell us if you want a total of two output messages, or if you want two output messages per input record? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jwende |
Posted: Tue Mar 01, 2005 2:41 pm Post subject: |
|
|
 Novice
Joined: 02 Jul 2001 Posts: 23
|
I didn't tried this live - but it may look like this ?
DECLARE A,B INTEGER 1;
DECLARE K INTEGER 1;
DECLARE L INTEGER CARDINALITY(InputRoot.MRM.DETAILS[]);
WHILE K <= L DO
IF InputRoot.MRM.DETAILS[K].FN='1'
THEN
SET Environment.A.DETAILS[A].FIRSTNAME =InputRoot.MRM.DETAILS[K].FN;
SET Environment.A..DETAILS[A].LASTNAME= InputRoot.MRM.DETAILS[K].LN;
SET A = A+1;
ELSE
SET Environment.B.MESSAGE.N[B].FN=InputRoot.MRM.DETAILS[K].FN;
SET Environment.B.MESSAGE.N[B].LN=InputRoot.MRM.DETAILS[K].LN;
SET B=B+1;
END IF;
SET K=K+1;
END WHILE;
-- propagate type 1
CALL CopyMessageHeaders();
SET OutputRoot.Properties.MessageSet = 'EBQDKJC002001';
SET OutputRoot.Properties.MessageType = 'FLOATMSG1';
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName = 'A';
SETOutputLocalEnvironment.Destination.MQ.DestinationData.queueManagerName ='BMB';
SET OutputRoot.MRM = Environment.A;
PROPAGATE;
--propagate type 2
CALL CopyMessageHeaders();
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName 'B;
SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueManagerName= 'BMB';
SET OutputRoot.XML = Environment.B;
PROPAGATE; |
|
Back to top |
|
 |
mahek |
Posted: Tue Mar 01, 2005 2:41 pm Post subject: |
|
|
Voyager
Joined: 10 Sep 2004 Posts: 87
|
Hi jefflowrey,
I am trying to get total two output messages here in this example all the records that have the FN =1 ON ONE QUEUE AND all other records whoes FN NOT EQUALS 1 to ANOTHER QUEUE.
I am getting the following error
BROK.AB ) (.FLOATMF_Compute.Main, 23.32) : Invalid indexed assignment to 'DETAILS[K]'.
No indexed elements from the named array exist. In order to assign a value to an element with index n, where 'n' is a positive integer, n-1 elements with the same name must already exist.
Ensure that element n-1 is created before an attempt is made to create element n. |
|
Back to top |
|
 |
JT |
Posted: Tue Mar 01, 2005 4:46 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
Ensure that element n-1 is created before an attempt is made to create element n. |
Look at the sample code provided by jwende.
You need to maintain distinct input & output (2) indices.
Your ESQL code attempts to create an output occurrence (does not matter which one) without ever having established the 1st occurrence. |
|
Back to top |
|
 |
mahek |
Posted: Wed Mar 02, 2005 9:06 am Post subject: |
|
|
Voyager
Joined: 10 Sep 2004 Posts: 87
|
Hi jwende,
Thanks very much for your help, it works the way you explained.
Once again thanks a lot to you all for the help. |
|
Back to top |
|
 |
|