anaghaphadke Posted December 27, 2010 Share Posted December 27, 2010 Hello All,I have set a patten to BigDecimal variable as ###0.00;-###0.00, but it is not working whenever amounts gets negative.e.g. for minus 9423 it should be shown as -9423.00 or (9423.00)Please help me to solve this problem-Anagha Link to comment Share on other sites More sharing options...
cbarlow3 Posted December 27, 2010 Share Posted December 27, 2010 I got this to work fine with the jrxml below (pattern was "###0.00;-###0.00"). This printed the negative value in question as:-9423.00If you wanted to include a comma separator and not include the zeroes after the decimal, you could instead use the pattern "#,##0;-#,##0", which prints the value as-9423.00Hope that helps!Carl Code:<textField pattern="###0.00;-###0.00"> <reportElement style="BandedTable" mode="Opaque" x="0" y="0" width="100" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{RANDNUM}]]> </textFieldExpression></textField> Link to comment Share on other sites More sharing options...
anaghaphadke Posted December 28, 2010 Author Share Posted December 28, 2010 Hello Carl,I changed the pattern of the field as per your suggestion, but still it is not showing as per requirement. Attaching herewith the Report where marked amount should be negative Please solve my problem Thanks & Regards,-Anagha Link to comment Share on other sites More sharing options...
anaghaphadke Posted December 28, 2010 Author Share Posted December 28, 2010 Ohh! Attachment missing Sorry for the inconvenience -Anagha Link to comment Share on other sites More sharing options...
cbarlow3 Posted December 28, 2010 Share Posted December 28, 2010 I'm starting to doubt that it's a problem with the pattern. Is that last column a field returned from your query or a calculated value within iReport? if it's a field that's returned from the query, have you used another tool to look at the raw data being returned by that same query to verify that those amounts are returned as negative? On the other hand, if that column is a calculated value (or a variable, which is also a calculated value--just one that happens to have a name for easy reuse), I'd be interested in seeing what the value expression is that defines it. My theory is that your "refund" amounts are still coming in as positive values and that you're going to have to either change your query or change the expression in iReport based on some other information.If you copy your JRXML and paste it into the "Code:" box, I can try to take a quick look.Carl Link to comment Share on other sites More sharing options...
anaghaphadke Posted December 29, 2010 Author Share Posted December 29, 2010 Hello Carl,Thanks Carl, My problem is solved.As per your suggestion, I checked my query, and I found that I am using abs function in query for the this column to return value.I removed and check the Report and its working now. Thank you once again. -Anagha Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now