cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Numeric strings and toNumber function

Former Member
0 Likes
2,633

Hello,

I'm having problems with Crystal Reports for Eclipse when using some reports.

The problem comes with reports that contain toNumeric function with a data that is get from the database, it gives an error that says the string is non-numeric even if it is a numeric string. The formula in the reports looks like this:

...
numberVar cantidad_dias := ToNumber({MYVIEW.NumericText});
...

I know that using isNumeric condition it works well, but it works well too when using Crystal Reports 2008 without any condition, so I think it should work for Crystal Reports for Eclipse and return error only in the case that the string isn't numeric. Is it a bug?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

The Log4J tells:

ERROR com.crystaldecisions.reports.saveddata.saveddata.DataView.a(SourceFile:1095) - Failed to evaluate recurring formulas
com.crystaldecisions.reports.formulas.FormulaException$FormulaProgrammingError: Excepción en la fórmula '{@formula1}' en '{MYVIEW.NumericText}':
La cadena es no numérica.
	at ...

It is in spanish, it means: exception in {@formula1} in '{MYVIEW.NumericText}': The string is not numeric.

As I said earlier, this report works fine at Crystal Reports 2008, I think it should work too with CR4E.

Thanks

Former Member
0 Likes

What happens if you have end your formula like so....


.
.
.
numberVar myNum;

myNum := ToNumber({MYVIEW.NumericText});

myNum;

Do you get the same error? It might just have an issue with declaring and assigning and returning everything all at once.

You also mentioned

All the returned values are true, so I think that there's no problem with the database values.

It's strange, because there's no problem if the formula finishes like this:


toNumber({MYVIEW.NumericText})

but the error appears if the formula contains something like this:


numberVar myNum := ToNumber({MYVIEW.NumericText})

Im sure it wont make a difference but you got a lower case toNumber in the working and an uppercase ToNumber in the issue.

But I still think give my initial test a try.

Thanks

Darren

Edited by: Darren Jackson on Oct 29, 2009 3:02 PM

Know this is not a solution to the problem from a CR4E point of view but

If you cant solve the problem in the report, is converting it to a number within the View an option?

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

If I can't duplicate the behavior, I can't help you.

And I really do want to duplicate the behavior, and help you.

Something is triggering this, and I don't see the trigger.

Sincerely,

Ted Ueda

Answers (7)

Answers (7)

Former Member
0 Likes

Hi all,

The issue was caused by the fact that the database contained null values.

Changing the formula as follow solved the issue

if ({VIEW.FIELD} < > "") then

numbervar var := tonumber({VIEW.FIELD})

Kind Regards,

Flavio Ceccarelli

Former Member
0 Likes

In my previous post I said that the error happens at assignation time, now, I have noticed that isn't true, the error appears if in the formula is an assignation, but the error happens at ToNumber function.

For example, as I have said, the following formula is correct:

ToNumber({MYVIEW.NumericText});

but the following formulas return error:

stringVar str := "123";
ToNumber({MYVIEW.NumericText});

or

ToNumber({MYVIEW.NumericText});
stringVar str := "123";

returning {MYVIEW.NumericText} is non-numeric string in both cases.

Former Member
0 Likes

I get the same error declaring, assigning and returning everything all in once, or doing it in three steps. I also have tried with uppercase and lower case and once again the same error appears when doing the exportation.

I think that it happens at the time of assignation, because only appears when using the assignation.

I have tried to do the assignation to a string with CStr(ToNumber({MYVIEW.NumericText})), based on Ted's previous advice, always the same error.

And also with:

stringVar myString := {MYVIEW.NumericText};
numberVar myNum := ToNumber(myString);
...

Thanks

Former Member
0 Likes

It tells that {MYVIEW.NumericText} isn't a numeric string, but I know it is numeric string.

I've tried what too you said about ToNumber(CStr(ToNumber({MYVIEW.NumericText}))) and it returns the same error again in the cases that ToNumber({MYVIEW.NumericText}) returned error.

Thanks

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

I really want to know specifically what string is causing that error...

How about Log4J? Does that tell you anything?

Sincerely,

Ted Ueda

Former Member
0 Likes

All the returned values are true, so I think that there's no problem with the database values.

It's strange, because there's no problem if the formula finishes like this:

toNumber({MYVIEW.NumericText})

but the error appears if the formula contains something like this:

numberVar myNum := ToNumber({MYVIEW.NumericText})

Thanks

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

That's a very interesting issue.

If you enable Log4J logging, does that tell anything as to what's causing the issue?

What happens if you do something really strange to combat the strangeness, like ToNumber(CStr(ToNumber({MYVIEW.NumericText}))), i.e., force Crystal Reports Java to format what it converted to a number to a string to a number?

Sincerely,

Ted Ueda

Former Member
0 Likes

I have printed all the values that are used by the function and are OK, but it still return error when using Crystal Reports for Eclipse.

Thanks for answering.

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

Then I would try printing out the function


    IsNumeric({MYVIEW.NumericText})

to see if any field comes up as false.

Sincerely,

Ted Ueda

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

I would print out the field {MYVIEW.NumericText} delimited by quotes, to see if it's a specific value that the function is tripping over.

Sincerely,

Ted Ueda