Author |
Message
|
Hitesh Jain |
Posted: Fri Dec 24, 2010 6:09 am Post subject: Dynamic queue manipulation using ESQL in WMBv6.2 |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
Hi i am having problem with the dynamic queue manipulation logic in my error handler esql. Here is my code sample...
If (errLabel ='ABC')Then
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE27';
Propagate TO TERMINAL 'out' Message InputRoot ;
Elseif (errLabel ='VFC_WMB_WCS_B2B_SERIAL')Then
IF (InputRoot.XMLNS.NSSALESREP01:SapYsalesrep01.SapYsalesrep01IDocBO.SapIDocControlRecord.IDOCTYP = SALESREPROSTERIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE26';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSYSAORST:SapYsaorst01.SapYsaorst01IDocBO.SapIDocControlRecord.IDOCTYP = ORDSTATUSIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE25';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSHRMDA1:SapHrmdA01Yhrmda1.SapHrmdA01Yhrmda1IDocBO.SapIDocControlRecord.Idoctyp =SALESREPMASTERIDOCTYP ) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE24';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSDEBMAS:SapDebmas04YDebmas.SapDebmas04YDebmasIDocBO.SapIDocControlRecord.IDOCTYP= CUSTMASTERIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE23';
Propagate TO TERMINAL 'out' Message InputRoot;
End if ;
Elseif (errLabel ='DEF')Then
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE22';
Propagate TO TERMINAL 'out' Message InputRoot;
Elseif (errLabel ='GHI')Then
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE21';
Propagate TO TERMINAL 'out' Message InputRoot;
Elseif (errLabel ='JKL')Then
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE20';
Propagate TO TERMINAL 'out' Message InputRoot;
Elseif (errLabel ='MNO')Then
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE28';
Propagate TO TERMINAL 'out' Message InputRoot;
Else
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE29';
Propagate TO TERMINAL 'out' Message InputRoot;
End if; |
|
Back to top |
|
 |
fatherjack |
Posted: Fri Dec 24, 2010 6:13 am Post subject: Re: Dynamic queue manipulation using ESQL in WMBv6.2 |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
Hitesh Jain wrote: |
Hi i am having problem with the dynamic queue manipulation logic |
Care to expand a little on your problem. _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
Hitesh Jain |
Posted: Fri Dec 24, 2010 6:59 am Post subject: |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
I want the answer whether i am doing wrong or right. If wrong then want the correct way for the manipulation |
|
Back to top |
|
 |
Hitesh Jain |
Posted: Fri Dec 24, 2010 7:01 am Post subject: |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
I want to manipulate different error IDOCS to different queues based on their IDocTyp so how will be i able to achieve this???? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Dec 24, 2010 7:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Hitesh Jain wrote: |
I want the answer whether i am doing wrong or right. |
Does the code work? |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Dec 24, 2010 7:47 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Nested If's are ok but IMHO above 3 or 4 nests it gets a bit messy
Look at the CASE statement.
It is a lot more readable and extensible _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Hitesh Jain |
Posted: Fri Dec 24, 2010 8:35 am Post subject: |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
Yeah sometimes it works and sumtimes it automatically fails and does not give any error.... |
|
Back to top |
|
 |
sankritya |
Posted: Fri Dec 24, 2010 6:59 pm Post subject: |
|
|
Centurion
Joined: 14 Feb 2008 Posts: 100
|
Quote: |
Elseif (errLabel ='VFC_WMB_WCS_B2B_SERIAL')Then
IF (InputRoot.XMLNS.NSSALESREP01:SapYsalesrep01.SapYsalesrep01IDocBO.SapIDocControlRecord.IDOCTYP = SALESREPROSTERIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE26';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSYSAORST:SapYsaorst01.SapYsaorst01IDocBO.SapIDocControlRecord.IDOCTYP = ORDSTATUSIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE25';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSHRMDA1:SapHrmdA01Yhrmda1.SapHrmdA01Yhrmda1IDocBO.SapIDocControlRecord.Idoctyp =SALESREPMASTERIDOCTYP ) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE24';
Propagate TO TERMINAL 'out' Message InputRoot;
ELSEIF (InputRoot.XMLNS.NSDEBMAS:SapDebmas04YDebmas.SapDebmas04YDebmasIDocBO.SapIDocControlRecord.IDOCTYP= CUSTMASTERIDOCTYP) THEN
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE23';
Propagate TO TERMINAL 'out' Message InputRoot;
End if ; |
What if errLabel ='VFC_WMB_WCS_B2B_SERIAL' and none of the condition meets?
I think you need to add a Default ELSE in this too like given below to get output in all cases.
ELSE
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE29';
Propagate TO TERMINAL 'out' Message InputRoot;
Prefer CASE over the Nested IF- ELSE. It simplifies your tasks and makes it Presentable too. |
|
Back to top |
|
 |
Hitesh Jain |
Posted: Fri Dec 24, 2010 10:36 pm Post subject: |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
I dont know how to use CASE statement instead of nested if so it will better if you provide me with a sample code snippet.... |
|
Back to top |
|
 |
sankritya |
Posted: Sat Dec 25, 2010 1:14 am Post subject: |
|
|
Centurion
Joined: 14 Feb 2008 Posts: 100
|
|
Back to top |
|
 |
Hitesh Jain |
Posted: Sat Dec 25, 2010 1:17 am Post subject: |
|
|
Novice
Joined: 24 Dec 2010 Posts: 16
|
Thanx for the link i will try it and will let you know |
|
Back to top |
|
 |
smdavies99 |
Posted: Sat Dec 25, 2010 1:47 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
One general point about the problem.
If you set the Output Detination Queue Name to be the one where you go in case of none of the IF conditions OR the CASE not giving you a match BEFORE you start the nested IF or the CASE, you will always have a value for the destination no matter what happens in the IF/CASE operation.
I actually prefer doing things like this, this way. IMHO, this is SOP in Defensive Programming. It is like setting a default value.
And with ESQL setting a value to NULL (and thus deleting it) if you get a path failure in a SET operation, it makes debugging the issue that much easier. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Dec 25, 2010 5:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
SET OutputLocalEnvironment.Destination.MQ.DestinationData[0].queueName ='TESTQUE27'; |
What happens if you start your index with 1 instead of 0?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|