Scripted Data Source Question

Hi All,

I am relatively new to BIRT reporting (approximately 6 months or so) and I am using version 3.7.2 with Eclipse. My understanding of java and javascript is limited at this point, but I catch on quick.

I am trying to create a scripted data source (set?)(I think this is what I need) to use in a report that's already using an XML data source. Currently, from the XML data source I have a data set and from it I have a text field (called userString1) that has a delimited format like so...

[category,value][startdate,date][enddate,date][somefield,value];[category,value][startdate,date][enddate,date][somefield,value]

Where each [,] represents a field with a label and a value and ; equals a new row. This format is flexible and can be altered to whatever, just trying to represent the fact that I have a field with data crammed in it that needs to be parsed and converted into fields and rows that can be used in a table.

Is it possible to use this field (userString1) from the XML data source to build a scripted data source? If not what other options do I have? I need place a table on my report that contains the data from userString1.

I am hoping that someone can provide me with a good example that will not only help me with this specific task, but also jump start my understanding of java while I read and get up to speed.

Thanks in advance.

David

Comments

  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Hi David,

    Yes, you can use a scripted dataSet to separate this field into multiple rows. In your original dataSet's onFetch script, you'd need to store the values into an array, to use in your scripted dataSet. Then, in your scripted dataSet, you'd step through the array and create your rows.

    Another possibility would be to just use script to separate the field into separate rows, in a text box, within the table bound to your original dataSet.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: mwilliams.silanis@gmail.com

  • mwilliamsmwilliams BIRT Guru
    edited December 1969

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: mwilliams.silanis@gmail.com

  • edited December 1969
    Thanks, would it be possible for you to provide a generic example of these? I have been struggling with this for a few days and want to make sure I have a good understanding.



    I will try what you have mentioned in the meantime and see if I can get it working.




    Hi David,



    Yes, you can use a scripted dataSet to separate this field into multiple rows. In your original dataSet's onFetch script, you'd need to store the values into an array, to use in your scripted dataSet. Then, in your scripted dataSet, you'd step through the array and create your rows.



    Another possibility would be to just use script to separate the field into separate rows, in a text box, within the table bound to your original dataSet.

  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Not sure if you saw my second post, or not. It has a link to an example of the scripted dataSet.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: mwilliams.silanis@gmail.com

  • edited December 1969
    Thanks, I just saw it. I think we replied at the same time. Reading over it now.




    Not sure if you saw my second post, or not. It has a link to an example of the scripted dataSet.

  • edited September 2012
    Hi mwilliams,



    I have been working on implementing the example you provided but I am getting hung up on the java part. Feel free to laugh at my java code because I don't have a clue. Just bought a couple java books yesterday because I need to learn it :). Here's what I have.



    userString1 has the following:

    202406-1|STIP|9/12/2011|9/12/2012|0|35000|0~68106-1|STIP|9/12/2011|9/12/2012|0|35000|0~68106-1|STIP|9/13/2013|9/12/2013|0|35000|0



    The XML data set beforeOpen

    incentiveTarget = [];



    The XML data set beforeClose

    reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);



    The XML data set onFetch

    incentiveTarget = row["userString1"].split("~");



    The scripted data set open

    incentiveTarget = reportContext.getPersistentGlobalVariable("incentiveTarget");
    currentRow = 0;
    totalRows = incentiveTarget.length;



    The scripted data set fetch

    if (currentRow < totalRows) {
    rowData = incentiveTarget[currentRow].split("|");
    row["id"] = rowData[0];
    row["category"] = rowData[1];
    row["startDate"] = rowData[2];
    row["endDate"] = rowData[3];
    row["minAmt"] = rowData[4];
    row["targetAmt"] = rowData[5];
    row["maxAmt"] = rowData[6];
    currentRow++;
    return (true);
    }
    return (false);





    The errors:

    Description	Resource	Path	Location	Type
    Caused by: org.eclipse.birt.data.engine.core.DataException: Column binding "category" has referred to a data set column "category" which does not exist.
    at org.eclipse.birt.data.engine.impl.ResultIterator.validateManualBindingExpressions(ResultIterator.java:375)
    at org.eclipse.birt.data.engine.impl.ResultIterator.<init>(ResultIterator.java:148)
    at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:212)
    at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
    at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
    at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
    at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
    at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
    ... 47 more
    CustomDesignFile.rptdesign /Reports/2.5.0/Mad Science/Total Compensation Data Structure line 15053 BIRT Viewer Problem
    org.eclipse.birt.report.engine.api.EngineException: Data Set script method "Fetch" returned null; expected a Boolean value. (Element ID:1)
    at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:244)
    at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:233)
    at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:165)
    at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch(ScriptDataSetRuntime.java:103)
    at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery.java:260)
    at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetchFromDataSet(DataSetToCache.java:242)
    at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetch(DataSetToCache.java:171)
    at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapter.java:218)
    at org.eclipse.birt.data.engine.executor.cache.RowResultSet.doNext(RowResultSet.java:113)
    at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:91)
    at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.next(ExpandableRowResultSet.java:63)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populateData(SmartCacheHelper.java:316)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInstance(SmartCacheHelper.java:285)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResultSetCache(SmartCacheHelper.java:246)
    at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCache.java:73)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populateOdiResultSet(PassUtil.java:132)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(PassUtil.java:62)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSinglePass(PassManager.java:170)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.prepareDataSetResultSet(PassManager.java:94)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.populateDataSetResultSet(PassManager.java:80)
    at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.cacheDataSet(ResultSetPopulator.java:203)
    at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init>(CachedResultSet.java:142)
    at org.eclipse.birt.data.engine.executor.CandidateQuery.execute(CandidateQuery.java:160)
    at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:226)
    at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1134)
    at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
    at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
    at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
    at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
    at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
    at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
    at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
    at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
    at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
    at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
    at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
    at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
    at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
    at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
    at org.eclipse.birt.report.engine.layout.html.HTMLListLM.layoutChildren(HTMLListLM.java:72)
    at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
    at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
    at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
    at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:929)
    at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
    at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
    at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
    at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
    at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
    at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:120)
    at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
    Caused by: org.eclipse.birt.data.engine.core.DataException: Data Set script method "Fetch" returned null; expected a Boolean value.
    at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:153)
    ... 76 more
    CustomDesignFile.rptdesign /Reports/2.5.0/Mad Science/Total Compensation Data Structure line 2 BIRT Viewer Problem
    org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "if (currentRow < totalRows) {
    rowData = incentiveTarget[currentRow].split("|");
    row["id"] = rowData[0];
    row["category"] = rowData[1];
    row["startDate"] = rowData[2];
    row["endDate"] = rowData[3];
    row["minAmt"] = rowData[4];
    row["targetAmt"] = rowData[5];
    row["maxAmt"] = rowData[6];
    currentRow++;
    return (true);
    }
    return (false);":
    Fail to execute script in function __bm_FETCH(). Source: " + if (currentRow < totalRows) {
    rowData = incentiveTarget[currentRow].split("|");
    row["id"] = rowData[0];
    row["category"] = rowData[1];
    row["startDate"] = rowData[2];
    row["endDate"] = rowData[3];
    row["minAmt"] = rowData[4];
    row["targetAmt"] = rowData[5];
    row["maxAmt"] = rowData[6];
    currentRow++;
    return (true);
    }
    return (false); + " A BIRT exception occurred. See next exception for more information.
    Error evaluating Javascript expression. Script engine error: ReferenceError: "totalRows" is not defined. (/report/data-sets/script-data-set[@id=";3412"]/method[@name=";fetch"]#1)
    Script source: /report/data-sets/script-data-set[@id=";3412"]/method[@name=";fetch"], line: 0, text:
    __bm_FETCH(). (Element ID:1)
    at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:99)
    at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:256)
    at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:143)
    at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch(ScriptDataSetRuntime.java:103)
    at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery.java:260)
    at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetchFromDataSet(DataSetToCache.java:242)
    at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetch(DataSetToCache.java:171)
    at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapter.java:218)
    at org.eclipse.birt.data.engine.executor.cache.RowResultSet.doNext(RowResultSet.java:113)
    at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:91)
    at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.next(ExpandableRowResultSet.java:63)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populateData(SmartCacheHelper.java:316)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInstance(SmartCacheHelper.java:285)
    at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResultSetCache(SmartCacheHelper.java:246)
    at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCache.java:73)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populateOdiResultSet(PassUtil.java:132)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(PassUtil.java:62)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSinglePass(PassManager.java:170)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.prepareDataSetResultSet(PassManager.java:94)
    at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.populateDataSetResultSet(PassManager.java:80)
    at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.cacheDataSet(ResultSetPopulator.java:203)
    at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init>(CachedResultSet.java:142)
    at org.eclipse.birt.data.engine.executor.CandidateQuery.execute(CandidateQuery.java:160)
    at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:226)
    at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1134)
    at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
    at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
    at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
    at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
    at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
    at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
    at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
    at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
    at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
    at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
    at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
    at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
    at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
    at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
    at org.eclipse.birt.report.engine.layout.html.HTMLListLM.layoutChildren(HTMLListLM.java:72)
    at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
    at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
    at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
    at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
    at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:929)
    at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
    at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
    at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
    at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
    at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
    at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:120)
    at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
    Caused by: org.eclipse.birt.data.engine.core.DataException: Fail to execute script in function __bm_FETCH(). Source: " + if (currentRow < totalRows) {
    rowData = incentiveTarget[currentRow].split("|");
    row["id"] = rowData[0];
    row["category"] = rowData[1];
    row["startDate"] = rowData[2];
    row["endDate"] = rowData[3];
    row["minAmt"] = rowData[4];
    row["targetAmt"] = rowData[5];
    row["maxAmt"] = rowData[6];
    currentRow++;
    return (true);
    }
    return (false); + "
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Make sure you have a report element bound to your XML dataSet prior to any element bound to your scripted dataSet in your report. The best thing to do, in a situation like this is to put a text box, bound to your original dataSet, at the very top of your design.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: mwilliams.silanis@gmail.com

  • edited September 2012
    Thanks Michael,



    The XML data set is bound to the list element. It has something to do with my java code, and I can't figure it out. I can output debug code and see that the userString1 text is making it to the XML onFetch, but for some reason my code is behaving differently from the example you provided.



    For example here's your example:



    beforeOpen

    eventID = [];
    eventTopic = [];
    eventAttendeeIDs = [];

    beforeClose

    reportContext.setPersistentGlobalVariable("eventID",eventID);
    reportContext.setPersistentGlobalVariable("eventTopic",eventTopic);
    reportContext.setPersistentGlobalVariable("eventAttendeeIDs",eventAttendeeIDs);

    onFetch

    eventID[eventID.length] = row["eventID"];
    eventTopic[eventTopic.length] = row["eventTopic"];
    eventAttendeeIDs[eventAttendeeIDs.length] = row["eventAttendeeIDs"].split(";");
    logToDebugWindow(eventAttendeeIDs);

    output from debug window

    268,254,24,167
    268,254,24,167,196
    268,254,24,167,196,392,161,173,352



    What I get with the same code:



    Using the following format.. row delimiter = ~ column delimiter = ;

    202407-1;STIP;9/12/2011;9/12/2012;0;35000;0~68107-1;STIP;9/12/2011;9/12/2012;0;35000;0~68107-1;STIP;9/13/2013;9/12/2013;0;35000;0

    beforeOpen

    incentiveTarget = [];

    beforeClose

    reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);

    onFetch

    if (row["userString1"] != "" ) {
    incentiveTarget[incentiveTarget.length] = row["userString1"].split("~");
    logToDebugWindow(incentiveTarget);
    }

    [Ljava.lang.String;@4e542
    [Ljava.lang.String;@4e542,[Ljava.lang.String;@701420



    Then I have noticed that the open for the scripted data set, reportContext.getPersistentGlobalVariable isn't working. Not sure if it has anything to do with Ljava.lang.String;@.....



    Best Regards



    David
  • edited September 2012
    Thanks for all your help Michael, I finally got it working. I can't share the design file because it contains lots of confidential info, but here's the code.



    Within the XML Data Set I populated userString1 with a delimited format I came up with for two people. This looks like the following:



    ~ is the row delimiter

    ; is the column delimiter



    22406-1;STIP;9/12/2011;9/12/2012;0;35000;0~6806-1;STIP;9/12/2011;9/12/2012;0;35000;0~6806-1;STIP;9/13/2013;9/12/2013;0;35000;0



    And



    22407-1;STIP;9/12/2011;9/12/2012;0;35000;0~6807-1;STIP;9/12/2011;9/12/2012;0;35000;0~6807-1;STIP;9/13/2013;9/12/2013;0;35000;0







    The data set code



    XML Data Set beforeOpen



    incentiveTarget = [];



    XML Data Set beforeClose



    reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);



    XML Data Set onFetch



    if ( row["userString1"] != "" ) {
    incentiveTarget[incentiveTarget.length] = row["userString1"].split("~");
    }



    Scripted Data Set open



    incentiveTarget = reportContext.getPersistentGlobalVariable("incentiveTarget");
    currentRow = 0;
    currentRecord = 0;
    totalRows = incentiveTarget.length;



    Scripted Data Set fetch



    if (currentRow < totalRows){
    record = incentiveTarget[currentRow];
    if (currentRecord < record.length) {
    rowData = record[currentRecord].split(";");
    row["id"] = rowData[0];
    row["category"] = rowData[1];
    row["startDate"] = rowData[2];
    row["endDate"] = rowData[3];
    row["minAmt"] = rowData[4];
    row["targetAmt"] = rowData[5];
    row["maxAmt"] = rowData[6];
    currentRecord++
    if (currentRecord == record.length) {
    currentRecord = 0;
    currentRow++;
    }
    return (true);
    }
    }
    return (false);
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Sorry for the delay. The forums are very backed up and I try to work from the back to the front, so I hadn't quite gotten to yours. Glad you got it working. I'm not sure I notice a difference between the code you were having a problem with and what finally worked. Was the issue just with the scripted dataSet? Or is there something I'm not noticing?

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: mwilliams.silanis@gmail.com

  • edited December 1969
    Hi Michael,

    The issue was in the way I was using both the onFetch to populate the array and then how I was grabbing and slicing the data out of my array in the fetch. I was all mixed up, but sorted it all out. :)

    Oh, and I did end up adding the text element up top because the table was nested in the list and wasn't working quite right.

    Best Regards

    David
Sign In or Register to comment.