Relational operator to compare value between string

Hi All,

I have two variable and i want to compare it as a string. I use BRANCH and set evaluate labels to “true” and i put relational operator as a condition. But i always got a problem if the value of those 2 variable is a number.
Let say i have below variable:

  • string1 = 000123
  • string2 = 123

when i compare it using relational operator %string1%==%string2%, the result is always equals. I read the service development guide and found that it is because wM treating those two value as a number. But what I want is to compare it as a string. I’ve tried using %‘string1’%=%‘string2’% or %“string1”%=%“string2”% as suggested in the guide but still not work.
I’m using wM v9.5.1.0.

really need your suggestion… thanks.

Its strange in webMethods. :lol:

if 123 and 0123 are integer types they are equal. If they are string they are not equal.

To check this functionality you can write your own java service

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
	String	inString1 = IDataUtil.getString( pipelineCursor, "inString1" );
	String	inString2 = IDataUtil.getString( pipelineCursor, "inString2" );
Boolean	flag;

flag=	inString1.equals(inString2);


// pipeline

IDataUtil.put( pipelineCursor, "flag", flag );
pipelineCursor.destroy();

Hi Mahesh,

Thank you for your fast response.
But my problem is, i unable to do comparison between 2 variable using relational operator %var1%==%var2% if those 2 variable value is a number.

Actually I need to create some validation to compare input from the filename (var1) with the value in database (var2).
So I create one BRANCH and set evaluate labels as true. Inside that BRANCH I put two maps with condition.
the label of first map is using relational operation, %var1%==%var2%, for the second map i’m using $default.
If the value is equal, then it will pass the validation. but if it is not, the it wont pass validation

-BRANCH
- %var1%==%var2%[1st condition -> filename is valid]
- $default [2nd condition -> filename invalid]

case1 :
Given below values,
var1 = "0RH0001"
var2 = "0KB0001"

Result : it wont pass the validation since 0RH0001 is not equals to 0KB0001, so it will always go to the $default map.

case2 :
Given below values (number),
var1 = "0001234"
var2 = "1234"

Result : It will pass the validation, by right it shouldn’t.

I’ve read service development guide for relational operator and found that it is because wM compare those value as a number, so 0001234 is equals to 1234.

This is what i read from the guide

So i change the condition and put quotes as suggested, but it is still not working.

Hope you understand my problem, really sorry if i make you confuse. Still learning.

thanks

Hi Mahesh,

Yap, i’m planning to create my own java services to do the comparison also.
But I just wonder, in the documentation, it is said that we can make wM to stop from treating the value as a number by using quotes, but when i tried, it can’t. wM still treating the value as a number.
do i miss something?? :smiley:

Before it reaches the Branch step try to concat " or ’ before and after file names

var1 = “0001234”
var2 = “1234”

then in Branch use %var1%==%var2%

I see you are right as per the guide but webMethods IS is not behaving as documented. May be you can use the alternate solution as of now.

Hi Sreenivas,

Yap, that can be one of the alternate solution too, Thanks for your input.

Hi Mahesh,

Yap, i guess i will handle this using my own service… Thanks yah

Thanks… now you know the solution. Have a nice day :slight_smile:

Hi Mahesh,

Just want to share, I finally use lexical operator to solve this solution.

%var1%L_EQUALS%var2%, If both value var1 & var2 is number, wM will compare it as a string.

thanks

Even I tried the same it works but its not a good practice, we use lexical operators in trigger filter conditions. I have never used it on IS.

Hi Mahesh,

May I know the reason why it is not a good practice? what is the impact? for my consideration…

I decided to use lexical operator because I want to compare the value as String only, and this is the only solution with the minimum changes, :smiley:

Hmm… I have never used it and never saw using lexical operators as evaluate expression for branching on IS in my experience.

If its working please go ahead :slight_smile: