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 » Dynamically constructed IF statement

Post new topic  Reply to topic
 Dynamically constructed IF statement « View previous topic :: View next topic » 
Author Message
petervh1
PostPosted: Fri Sep 17, 2021 5:58 am    Post subject: Dynamically constructed IF statement Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 122

Hi

IIB 10.0.0.14

I'm trying to dynamically build an IF statement and then execute it.

I've managed to build
Code:
'IF Environment.item.Costcentre <> 00001 AND IF Environment.item.Costcentre <> 00002 AND IF Environment.item.Costcentre <> 00003'

as a string inside
Code:
Environment.COSTCENTRECHECK


and tried to execute it using
Code:
IF EVAL('(Environment.COSTCENTRECHECK)') THEN ...


I get:
Code:
BIP2474 A Search condition must produce a boolean result


Can someone assist me with the required format of the EVAL?

TIA
Back to top
View user's profile Send private message
timber
PostPosted: Fri Sep 17, 2021 6:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Using EVAL is usually a terrible idea. What is the technical task that you are trying to accomplish?
Back to top
View user's profile Send private message
petervh1
PostPosted: Fri Sep 17, 2021 7:03 am    Post subject: Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 122

I need to check whether a cost centre element that is part of an input XML structure is represented or is not represented in a list of cost centres. The list of cost centres is supplied to the IIB flow by means of a JSON array which I need to parse and then construct a an IF statement.
Back to top
View user's profile Send private message
timber
PostPosted: Fri Sep 17, 2021 3:16 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

This is a very common task, and you do not need EVAL.

You should
- store the values from the JSON list in the Environment
- use the IN operator to see whether the XML value is in that list.

Give it a try, and post again if you cannot get it to work.
Back to top
View user's profile Send private message
petervh1
PostPosted: Mon Sep 20, 2021 1:34 am    Post subject: Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 122

I got it to work using "IN".

Thanks for your help.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Sep 20, 2021 3:52 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9394
Location: US: west coast, almost. Otherwise, enroute.

Please share your successful code for the benefit of others.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
petervh1
PostPosted: Mon Sep 20, 2021 4:09 am    Post subject: Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 122

The purpose of checking whether a cost centre is in a list was to determine whether a flag should be set to TRUE or FALSE.

Here's the code:
Code:

DECLARE CostCentreExists BOOLEAN;
SET Environment.item.[] = InputRoot.XMLNSC.item.[];
       
        IF InputRoot.XMLNSC.item.Costcentre IN(
          Environment.item.costcentrelist[]) THEN
            SET CostCentreExists = TRUE;
         ELSE
            SET CostCentreExists = FALSE;
         END IF;
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 » Dynamically constructed IF statement
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.