cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing API to keep parameter as String.

Former Member
0 Kudos

Hi again..

I recently made a post about having difficulties with the Date type parameter (llegalArgumentException when trying to schedule report w/ Date param(s)) not being accepted as a valid parameter.

Ted Ueda was nice enough to post a solution to that (using Date(...)) in the setValue method but unfortunately that turned me onto the actual problem.

Once I sent the report a Date parameter it continued to error and further investigation has shown that the report actually expects a String for a date... the report parses it. The report expects a String in the format of yyyyMMdd and it handles the conversion from there.

At first I was very confused by this because of course I was setting a String in the java api of value "20081011". I believe what might be happening is that the API seeing that the String is just numbers is converting it to some other datatype... then when it arrives at the report an error occurs because it is expecting a String and not a Number.

So my question is basically... is there a way to force this parameter to remain a String? I've tried "String(yyyyMMdd)" and various other things but I've yet to find anything that works

Below is the error that is returned from the crystal server when trying to pass "Date(2008,10,11)" as a parameter:

Error in formula <dayRange>.

'MonthName(ToNumber(Mid({?prm_txt_startDate_1}, 5,2))) + " " + ToText(ToNumber(Right({?prm_txt_startDate_1}, 2)), 0) +

The string is non-numeric.

Details: errorKind

Thanks again for the help with the previous problem and for any advice anyone can provide for this situation.

Accepted Solutions (1)

Accepted Solutions (1)

aasavaribhave
Advisor
Advisor
0 Kudos

Hi,

If you open the report in Crystal Designer, and look at the parameter properties under type does it show Date or DateTime or does it show String? If it shows String then you need to pass the date just as any other string parameter. If the type is Date then you must pass the parameter value as suggested by Ted.

Thanks

Aasavari

Former Member
0 Kudos

Hi, thanks for the reply!

The Crystal report itself expects a STRING value not a DATE in this case. The report expects the date-string in format of yyyyMMdd.

The problem is when I try to pass this value directly the crystal api throws an 'IllegalArgumentException: Invalid Argument Type" ... at first I thought this was because I needed to pass it a Date but once I had figured that out I realized that it actually needs a String but for some reason was still throwing errors.

The only thing I can think of (and this is a bit of a guess) is that the API seeing a String composed only of numbers 'casts' the value to a Number which then causes the IllegalArgumentException.

So... I'm wondering if there is a way to explicitly force the value to be a String? Much like the Date(...) syntax offered by Ted.

Former Member
0 Kudos

Just a shot in the dark here for a work around but what happens if you add a character to the end of

your DateString. "20081011a" to force it to be a string, and then strip off the character once you use it

in the report.

I know this is a very messy way of doing it but just a thought.

As to why you having this problem in the first place I cant help,

How are you obtaining the 20081011 in the first place, maybe you need to look a step further back

as to why its not storing it as a pure string.

Hope that helps a little.

Darren

fritzfeltus
Product and Topic Expert
Product and Topic Expert
0 Kudos

A Crystal Reports function which converts most datatypes to strings is ToText(), give that a shot.

ToText (20081209)

Former Member
0 Kudos

Hey, thanks for more suggestions everyone.

I've actually tried putting a char at the end of the string (a space) and that did sort of work... I didn't get IllegalArgumentException but the report did throw some error about trying to load data. I think the report breaks the date-string up using a substring that takes a start index to the end of the string so that extra character is causing problems still.

I've tried to ToText(...) 'function' before too unfortunately without any success but thanks for mentioning it all the same.

Former Member
0 Kudos

HI ,

I am also getting IllegalArgumentException ( See my post about IllegalArgumentException on getHtmlContent call ).

I have date parameters that are in the report as text and i am passing value as "12092008" so looks like i am also in the same boat for this error. Please let me know if you find the solution and post the solution . I will do the same if i will find anything.

Thanks.

Former Member
0 Kudos

I noticed that i was getting IllegalArguementException because the RPT was somehow corrupted.. I modified the RPT in the Crystal Report it self with verify database ( Database-> Verify Database ) and passing the parameters and saved it again and it did the trick somehow and now i am not getting that IllegalArguementException from the query engine.

Answers (0)