Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: Formula expression

  1. #1
    Join Date
    Jul 2006
    Posts
    18

    Default Formula expression

    I'm trying to use a formula expression with the simple xml format of report definition, but I can´t generate the report, an error occurs with no text explanatory of it.
    This is the item definition:

    <number-field x="500" y="0" width="58" height="10" alignment="right" formula="report:[impd]-[imph]" format="#,###,###,##0.00" />

    Were impd and imph are columns that are printed correctly in individual columns of the same report.

    What I'm doing wrong?

    Best Regards and Happy New Year!!!!
    Conxita

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    your formula looks correct. But can you give a bit more information?

    What error? Any log messages, exceptions, anything? How did you know there was an error?
    What versions of the engine do you use?

    Have fun,
    said Thomas
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3
    Join Date
    Jul 2006
    Posts
    18

    Default

    Sorry. I attach the output generated, the last line of the output is the error generated by my application when I call the function parseReport ().

    Thanks for your help.

    Conxita.
    Attached Files Attached Files
    Conxita

  4. #4
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Error asignando datos al report

    ?

    Well, you do not log the exception that causes your troubles so the log is 100% useless. It shows that the engine boots correctly, but afterwards it just prints that single non-informative line. Please give us the exception (and its stacktrace) that caused that error message.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  5. #5
    Join Date
    Jul 2006
    Posts
    18

    Default

    Hi.

    I debbuged my java program with eclipse , step by step and I see that the line marked (<-----) in the jfree code throws an exception that after I catch in my program.

    If I comment (<!-- -->) the item definition with the formula expression in the xml file , the report is ok, so the problem is in that line.


    private JFreeReport parseReport(URL in) throws ReportDefinitionException
    {
    if (in == null)
    {
    throw new ReportDefinitionException("ReportDefinition Source is invalid");
    }
    try
    {
    ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    Resource res = manager.createDirectly(in, JFreeReport.class); <---------
    return (JFreeReport) res.getResource();
    }
    catch(Exception e)
    {
    throw new ReportDefinitionException("Parsing failed", e);
    }
    }

    I attach the complete xml file, maybe it will give some light to the problem.

    Thanks for your help.
    Attached Files Attached Files
    Conxita

  6. #6

    Default

    Hi,

    As the formula stuff is considered as working we think that the problem belongs to your side. So could you try to past to us the full stack trace of the exception that occured? I think it is the fastest way to get a solution to your problem because it is too much time consuming to debug every user report definition.
    May the Moo force be with you,
    Said Mimil

    A student of JFree & Pentaho Academies,
    Cedric Pronzato

  7. #7
    Join Date
    Jul 2006
    Posts
    18

    Default

    Hi.

    I have done the homework. I have modified my source in order to print the stack trace and I post it below.

    Here is the extract of my xml definition where is the problem:

    <number-field x="340" y="0" width="58" height="10" alignment="right" fieldname="impd" format="#,###,###,##0.00" />

    <number-field x="420" y="0" width="58" height="10" alignment="right" fieldname="imph" format="#,###,###,##0.00" />

    <number-field x="500" y="0" width="58" height="10" alignment="right" formula="report:[impd]-[imph]" format="#,###,###,##0.00" />

    If I comment the third line, the report is ok, it prints imph and impd, but when I uncomment the third line, the engine throw an exception. It says "Fieldname is not set" .

    Stacktrace:

    INFO: Pentaho Reporting Classic 0.8.9.1 started.
    org.jfree.report.demo.util.ReportDefinitionException: Parsing failed
    at reports.LanzaReport.parseReport(LanzaReport.java:196)
    at reports.LanzaReport.<init>(LanzaReport.java:111)
    at reports.LanzaReport.main(LanzaReport.java:205)
    ParentException:
    java.lang.IllegalStateException: Fieldname is not set.
    at org.jfree.report.elementfactory.NumberFieldElementFactory.createElement(NumberFieldElementFactory.java:182)
    at org.jfree.report.modules.parser.simple.readhandlers.AbstractElementReadHandler.doneParsing(AbstractElementReadHandler.java:496)
    at org.jfree.xmlns.parser.AbstractXmlReadHandler.endElement(AbstractXmlReadHandler.java:161)
    at org.jfree.xmlns.parser.RootXmlReadHandler.endElement(RootXmlReadHandler.java:591)
    at gnu.xml.aelfred2.SAXDriver.endElement(SAXDriver.java:860)
    at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1043)
    at gnu.xml.aelfred2.XmlParser.parseContent(XmlParser.java:1207)
    at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1038)
    at gnu.xml.aelfred2.XmlParser.parseContent(XmlParser.java:1207)
    at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1038)
    at gnu.xml.aelfred2.XmlParser.parseContent(XmlParser.java:1207)
    at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1038)
    at gnu.xml.aelfred2.XmlParser.parseDocument(XmlParser.java:416)
    at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:167)
    at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
    at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
    at org.jfree.xmlns.parser.AbstractXmlResourceFactory.create(AbstractXmlResourceFactory.java:201)
    at org.jfree.resourceloader.ResourceManager.performCreate(ResourceManager.java:455)
    at org.jfree.resourceloader.ResourceManager.create(ResourceManager.java:383)
    at org.jfree.resourceloader.ResourceManager.create(ResourceManager.java:329)
    at org.jfree.resourceloader.ResourceManager.createDirectly(ResourceManager.java:315)
    at reports.LanzaReport.parseReport(LanzaReport.java:191)
    at reports.LanzaReport.<init>(LanzaReport.java:111)
    at reports.LanzaReport.main(LanzaReport.java:205)

    Thanks for your help.
    Conxita

  8. #8
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Ack. This is a bug in the report-engine. JIRA case for this is PRE-225; and the fix is now already in the SVN repository.

    The only workaround I can offer (until we release 0.8.9.3 later this month), is to switch from a value-expression to a named expression:

    <number-field x="500" y="0" width="58" height="10" alignment="right" formula="impdiff" format="#,###,###,##0.00" />

    and in the functions section:

    <functions>
    ..
    <function name="impdiff" formula="report:[impd]-[imph]"/>
    ..
    </functions>
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  9. #9

    Default

    Hi,

    As you could see under Taqua nickname, you can notice the "Reporting Bug Planter" sentence =)
    BTW thx conxita for the reporting this problem, Taqua is doing a great job and impooving a lot of things but sometimes a bug emerge.
    Last edited by Mimil; 01-09-2008 at 03:26 PM.
    May the Moo force be with you,
    Said Mimil

    A student of JFree & Pentaho Academies,
    Cedric Pronzato

  10. #10
    Join Date
    Jul 2006
    Posts
    18

    Default

    Thank for your great work and thanks also to take care as good of your community.
    I will wait impatiently the next release. The use of formula expression will save to me a lot of work. Now I prefer to do the data calculations at Database side to avoid the cumbersome named expressions.
    Conxita

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.