ListReports

Aus FreiBier
Wechseln zu: Navigation, Suche

I want to print a list of records. I want to use JasperReports for that (but the problme is similar with the internal report engine). If I press the Report button in any adempiere window I get a standard report with only one entry - the record that is activated. I want to print the whole list of records. If we can do that one can select some records with the search button and then print a nice list of them.

See http://jira.idempiere.com/browse/IDEMPIERE-270

Inhaltsverzeichnis

Technical research

first problem

The report is called vie the method

 org.compiere.apps.APanel.cmd_report()

In this method a new query is constructed that gets only the one record. This query is given as a parameter to "new AReport(...)". This is the Constructor for the Report.

AReport has no chance of getting the right information without taking the query or m_Tab as a parameter.

CarlosRuiz gave me two links to similar issues:

solution

It should be an easy solution just to give the right query as a parameter. I tried it (just one line of code) and it seems to work.

CarlosRuiz proposed to change it and make it configurable via a Sysconfig Parameter.

My solution is https://bitbucket.org/CarlosRuiz_globalqss/adempiere361/pull-request/15/idempiere-270-step1-works-for-internal


second problem

In AReport the method org.compiere.print.AReport.launchReport() gives the query parameter to the "new ReportEngine(...)" call. But if you use JasperReports it goes a second codepath. It calls a worker Process with a ProcessInfo object. There is no parameter for the query.

There is a parameter for the window number. With some hacking this might lead to a sql select string that is contained in the context. So not everything is lost yet.

Later in org.compiere.apps.ProcessCtl.startProcess() the process is started with

 return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx);

At this point no information that may lead to the query is given. :-(

If I do not want to change the whole hierarchy of call on the stack trace It seems the only possibility to enter the query into a copy of the context and give this as a parameter instead of getCtx(). At this point the windowNo is accessible. It should be possible with minor changes to the API to let even the query string be accessible.

There is a Key "_TabInfo_SQL" in the Context with a complete SELECT statement. Perhaps we can create an ORDER and an WHERE entry while creating this one. We could create keys for _JASPER_WHERE, _JASPER_TAB, _JASPER_WINDOW, _JASPER_ORDERBY, _JASPER_WHEREEXTENDED.

Because it is possible to start more than one report simultaneous we should use the form 4|1|JASPER_TAB.

For this to work we need the information which window we use. One idea was to use "global variable overloading" and to create a new Properties Object wth the Context as default. The window information can even go into the ProcessInfo object. We may add two new fields for window and tab or for a windowno and tabno. It seems better to use just numbers to separate the Processes from the UI.

third problem

While solving the seconf problem I realized that a Jasper Report that uses the _Report_OrderBy Context value is always sorted like defined in the configuration of the Tab. If the user changed the order by clicking on a column header he might get not the report he expected.

The point to solve that may be to store an alternative order clause. We may get this via m_curTab.getTableModel().sort() method that should remember the sort order in some field that we can access when constructing our context values.

Meine Werkzeuge
Namensräume

Varianten
Aktionen
Navigation
Werkzeuge