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 » replacing multiple repeating esql statements

Post new topic  Reply to topic
 replacing multiple repeating esql statements « View previous topic :: View next topic » 
Author Message
neo_revolution
PostPosted: Tue Feb 17, 2004 1:45 pm    Post subject: replacing multiple repeating esql statements Reply with quote

Voyager

Joined: 21 Oct 2003
Posts: 80
Location: NJ

Hi,

I need to create multiple output messages. I am using PROPAGATE and able to output multiple XML messages.

When creating XML I am creating XML values after each propagate.

In the output XML only one of the fields is changing, for remaining fields the values remain same. Is there a way to avoid repeating the code of creating same fields again and again... like using CREATE PROCEDURE and calling the procedure...

Thanks.

my multiple output xml

msg1
<country>
<name>abcd</name>
<state>ca</state>
<city>xxxx</city>
<seqno>1</seqno>
</country>

msg2
<country>
<name>abcd</name>
<state>ca</state>
<city>xxxx</city>
<seqno>2</seqno>
</country>

msg1
<country>
<name>abcd</name>
<state>ca</state>
<city>xxxx</city>
<seqno>2</seqno>
</country>

instead of creating or setting values multiple time is there a way to minimize code?
Back to top
View user's profile Send private message Yahoo Messenger
neo_revolution
PostPosted: Tue Feb 17, 2004 2:36 pm    Post subject: Reply with quote

Voyager

Joined: 21 Oct 2003
Posts: 80
Location: NJ

Thanks guys...

I got the solution... by using If then....

But I was getting same output XML... by checking generate ID for the output node I was able to see different XML messages I created.
Back to top
View user's profile Send private message Yahoo Messenger
Missam
PostPosted: Tue Feb 17, 2004 7:55 pm    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

It'll be much Better if you use While Loop To Propagate Multiple Messages
You can find an example for this in ESQL Reference
Back to top
View user's profile Send private message
neo_revolution
PostPosted: Wed Feb 18, 2004 7:56 am    Post subject: Reply with quote

Voyager

Joined: 21 Oct 2003
Posts: 80
Location: NJ

I implemented While loop and used the counter to propogate multiple messages.

I am using MQJ, for multiple messages when I browse the messages I am getting same message with same values... are we actually getting same message? because when I checked the option "Generate Message ID" for the Output Queue the MQJ showed messages 3 different messages with varied content...

Thanks
Back to top
View user's profile Send private message Yahoo Messenger
Missam
PostPosted: Wed Feb 18, 2004 9:05 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

There may be two reasons for getting same messages (content)

1)you may me supplying the Input message with duplicate content
2)You are Propogating same message in your while loop of compute node

your compute node sholud like this for propagate

Code:

DECLARE J INTEGER;
DECLARE K INTEGER;
SET J = 1;
SET K = CARDINALITY(InputRoot.XML."Message"[]);

WHILE(J <= K) DO

   SET OutputRoot.Properties = InputRoot.Properties;
   SET OutputRoot.MQMD = InputRoot.MQMD;
   SET OutputRoot.MQMD.Format = MQFMT_RF_HEADER_2;
   SET OutputRoot.MQRFH = InputRoot.MQRFH;
   SET OutputRoot.MQRFH2 = InputRoot.MQRFH2;
   SET OutputRoot.MQRFH2.(MQRFH2.Field)Version = 2;
   SET OutputRoot.MQRFH2.(MQRFH2.Field)Format= MQFMT_RF_HEADER_2;

   SET OutputRoot.XML.Message = InputRoot.XML."Message"[J];
       
   PROPAGATE;
   SET J = J + 1;

END WHILE;
RETURN FALSE;


Last edited by Missam on Tue Mar 02, 2004 11:05 am; edited 1 time in total
Back to top
View user's profile Send private message
EvolutionQuest
PostPosted: Tue Mar 02, 2004 8:03 am    Post subject: Reply with quote

Voyager

Joined: 18 Sep 2001
Posts: 88
Location: Billings, MT

I tried IamSam's code for an MRM, but the darn thing isn't working for me. I of course am losing the records passed the first one, and I don't recall how to keep the message so it'll parse through it. This is what I get when I don't work with propagate for 3 years
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EvolutionQuest
PostPosted: Tue Mar 02, 2004 9:32 am    Post subject: Reply with quote

Voyager

Joined: 18 Sep 2001
Posts: 88
Location: Billings, MT

Figured it out.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EvolutionQuest
PostPosted: Tue Mar 02, 2004 10:46 am    Post subject: Reply with quote

Voyager

Joined: 18 Sep 2001
Posts: 88
Location: Billings, MT

OK, I spoke to quickly.

Below is the ESQL I have in the compute node. When I purposely change J from 1 to 0 I check the trace and see both records I am sending, but when I have J = 1 and send a message I only get the first one. The second one is toast.

Any ideas?

DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
SET OutputRoot.Properties.MessageSet = 'DR563VG0N8001';
SET OutputRoot.Properties.MessageType = 'FullName_2';
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.

DECLARE J INTEGER;
DECLARE K INTEGER;
DECLARE FULLNAME REFERENCE TO "InputBody";
SET J = 1;
SET K = CARDINALITY("InputBody"."FullName"[]);

WHILE(J <= K) DO


SET OutputRoot.Properties = InputRoot.Properties;
SET OutputRoot.MQMD = InputRoot.MQMD;
SET OutputRoot.Properties.MessageDomain = 'MRM';
SET OutputRoot.Properties.MessageFormat = 'TDS';

SET "OutputRoot"."MRM"."FullNameRev"."LastName" = RTRIM(FULLNAME."FullName"."LastName"[J]) || ',';
SET "OutputRoot"."MRM"."FullNameRev"."FirstName" = FULLNAME."FullName"."FirstName"[J];
SET "OutputRoot"."MRM"."FullNameRev"."MiddleName" = FULLNAME."FullName"."MiddleName"[J];

PROPAGATE;
SET J = J + 1;

END WHILE;
RETURN FALSE;
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EddieA
PostPosted: Tue Mar 02, 2004 11:10 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Chris,

You're only setting the MessageType and MessageSet for the first message. After the Propogate ALL the Output trees are empty. So, at the top of your While, after moving Properties, you need to re-set the Type and Set.

Cheers,
Eddie
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
EvolutionQuest
PostPosted: Tue Mar 02, 2004 11:36 am    Post subject: Reply with quote

Voyager

Joined: 18 Sep 2001
Posts: 88
Location: Billings, MT

Eddie,

If I understand you the following should be within the WHILE after copying the OutputRoot.Properties = InputRoot.Properties:

Code:

SET OutputRoot.Properties.MessageSet = 'DR563VG0N8001';
SET OutputRoot.Properties.MessageType = 'FullName_2';


If this is correct it did not work. I have tried so many combinations it can not be this difficult from what I can recall.

Chris
P.S. When you see Todd say hello
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EddieA
PostPosted: Tue Mar 02, 2004 11:47 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Chris,

Yep, that's what I was saying. Otherwise the Type and Set are filled in from the Input Properties.

Spotted something else:
Quote:
SET K = CARDINALITY("InputBody"."FullName"[]);

So, FullName is the repeating element. In which case, shouldn't it be:
Code:
SET "OutputRoot"."MRM"."FullNameRev"."LastName" = RTRIM(FULLNAME."FullName"[J]."LastName") || ',';
SET "OutputRoot"."MRM"."FullNameRev"."FirstName" = FULLNAME."FullName"[J]."FirstName";
SET "OutputRoot"."MRM"."FullNameRev"."MiddleName" = FULLNAME."FullName"[J]."MiddleName";


Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
EvolutionQuest
PostPosted: Tue Mar 02, 2004 11:56 am    Post subject: Reply with quote

Voyager

Joined: 18 Sep 2001
Posts: 88
Location: Billings, MT

Thanks Eddie!

What a dork I am. I should of caught the proper location to reference the array.

Chris
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » replacing multiple repeating esql statements
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.