cancel
Showing results for 
Search instead for 
Did you mean: 

Error in number function

Former Member
0 Kudos

When the execute the following in the link editor,

number(stringreplace( stringtrim("000000000000000067" ), 0, 1 )

I am getting the following the following value:

111111111111111168

What is going on here? Any clue? Is it a bug in xMII?

Thanks,

Sara

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

What is it that you are <i>really</i> trying to do? Are you looking to validate that a string contains only numeric values (not alpha-numeric)? Are you trying to perform numeric calculations on these string values?

0000000000009999 IS a string (with or without quotes).

Former Member
0 Kudos

Trying to find out if the given value is a string or number.

Thanks,

Sara

Former Member
0 Kudos

OK, so to you, is 000000000000000067 a string or a number?

Former Member
0 Kudos

It is a number field.

Thanks,

Sara

Former Member
0 Kudos

No, 000000000000000067 is a string. It may be made up of 18 number characters, but it is a string. If you use the number(000000000000000067) in BLS, you get "67" (as you know, which is part of your issue).

That's why I am asking what you are really trying to accomplish. BLS is giving you the answer. It might not be the answer you are looking for, but it is giving you the right answer.

So are you really trying to validate that the string (ie, 000000000000000067) contains only numeric characters? What about validating that the string is a certain length?

You'll need to go through each character and make sure the current character is 0,1,2,3,4,5,6,7,8 or 9 - or at least until the match() function is working again.

Former Member
0 Kudos

Or, you could write a new action block that implemented the old "match" function pretty easily...homework assignment!

jcgood25
Active Contributor
0 Kudos

Sara,

The proper syntax would be (quotes and parenthesis missing):

number(stringreplace(stringtrim("000000000000000067"), <b>"</b>0<b>"</b>, <b>"</b>1<b>"</b>)<b>)</b>

Even with this correction the number function is doing something strange since if you remove one of the zeros it works - maybe a character limitation somehow?

I would encourage you to enter a bug into the customer/partner support portal so that it can be addressed. Please let me know if you are able to do this.

Best Regards,

Jeremy Good

Former Member
0 Kudos

number(stringreplace(stringtrim("000000000000000067"), "0", "1"))

also returns the wrong value.

I will file a bug in SAP support.

Thanks,

Sara

Former Member
0 Kudos

Probably not a bug, since it has to be converted to floating point (bigger than the largest integer).

Former Member
0 Kudos

If you remove the "number()" function, it works just fine.

What is the purpose of using the number() function if the all characters in the string are numeric?