Clarity

  • 1.  BigDecimal conversion error.

    Posted Sep 25, 2018 01:21 PM

    Hi Everyone,

     

    I am having an issue that occurs when I run a JasperSoft Studio report that it returns the below error message;

     

    "Value 0 of type java.lang.String unsupported for BigDecimal conversion"

     

    I cannot seem to pinpoint where the error or issue is occurring?  Any assistance would be greatly appreciated.  I have attached both the .jrxml files, the main report and sub report.

     

    I am currently running JasperSoft Studio 6.4.1 and JasperSoft Server 6.x.x.

     

    Any assistance would be greatly appreciated!!

     

    Thank You & Regards



  • 2.  Re: BigDecimal conversion error.

    Posted Sep 26, 2018 12:37 AM

    My 5min review of your code, in most of your variable definitions, you have logic like:

    (($F{PROJ_TYPE} == "2") ? $F{AVAIL_1}: "0")

     

    PROJ_TYPE is defined as Big Decimal, and I believe in the above statement you are then comparing to a String of value "2".  I might be wrong as I would have normally defined PROJ_TYPE as an Integer and the comparison would then have been $F{PROJ_TYPE} == 2 - I am assuming that PROJ_TYPE will only contain Integer values.  I also don't normally do Big Decimal comparisons due to rounding so I may be incorrect on the above.  You also also returning a value of "0" into this variable which is defined as a Big Decimal, so it may also be treating the "0" as a String as well.



  • 3.  Re: BigDecimal conversion error.

    Posted Sep 26, 2018 07:49 AM

    Hi Roland,

     

    Thank you for your input, much appreciated.  When I convert the $F{PROJ_TYPE} to an integer, I am still seeing the below error in the expression editor?

     

    $V{vDemand1}

     

    I did try compiling the report after changing the field type, however, it still showed the above error message?  Do both fields have to be of the same type in order for the If Then Else to work properly?  The field $V{vDemand1} represents hours for a month, so returning 0 makes sense to me, should I do it another way then?

     

    I really appreciate your assistance.

     

    Regards

    Jonathan



  • 4.  Re: BigDecimal conversion error.

    Posted Sep 26, 2018 10:34 AM

    Hi Roland,

     

    I was able to correct the issue with the expression, it should be listed as follows:

     

    variable name="vDemand1" class="java.math.BigDecimal" resetType="Group" resetGroup="Resource" calculation="Sum">
            <variableExpression><![CDATA[$F{PROJ_TYPE} == 2 ? $F{AVAIL_1} : new java.math.BigDecimal(0.0)]]></variableExpression>
            <initialValueExpression><![CDATA[new java.math.BigDecimal(0.0)]]></initialValueExpression>
     </variable>

     

    Now that I have no errors in the sub report, I seem to be getting this new error now,

     

     

    ??

     

    Thanks



  • 5.  Re: BigDecimal conversion error.

    Posted Sep 26, 2018 05:35 PM

    Not sure if this this is your issue but vDetailTotal is defined simaliar to vDemand1. Did you do same changes for vDetailTotal? 

     

    <variable name="vDetailTotal" class="java.math.BigDecimal" resetType="Group" resetGroup="Resource">
    <variableExpression><![CDATA[$F{PROJ_TYPE} == "2" ? $F{AVAIL_1} + $F{AVAIL_2} + $F{AVAIL_3} + $F{AVAIL_4} + $F{AVAIL_5} + $F{AVAIL_6} + $F{AVAIL_7} + $F{AVAIL_8} + $F{AVAIL_9} + $F{AVAIL_10} + $F{AVAIL_11} + $F{AVAIL_12} : "0"]]></variableExpression>
    <initialValueExpression><![CDATA[0]]></initialValueExpression>
    </variable>



  • 6.  Re: BigDecimal conversion error.

    Posted Sep 27, 2018 09:23 AM

    Hi Steve,

     

    I found that and corrected it, thanks.  I have made a lot of progress since the other day, my next issue seems to be Variables within Groups that are presenting a zero versus the actual hours that should be present,

     

     

    The Months values that say null are also not presenting.  Any thoughts?

     

    I am using the following formula in the variable fields for Capacity, $F{PROJ_TYPE} != 2 ? $F{AVAIL_1} : 0, $F{PROJ_TYPE} is a java.lang.Integer and $F{AVAIL_1} is a java.math.BigDecimal and the Evaluation Time field is set to "Now" and the Group Change is set to "Total".

     

    Thanks Again Everyone, I really appreciate the assistance.

     

    Regards