Finding Report Parameters

This article illustrates how to locate the parameters you will need to build custom reports using the OpenRPT report writer embedded within xTuple ERP.

Since a lot of people have asked essentially the same question, here is the method to find the answer to the question, "What are the parameters available to report SampleReport?" We'll use the Print Item Labels report as an example, presenting first a conceptual statement then sample command lines and output for a *NIX environment.

  1. Obtain the source code for the xTuple ERP application.
  2. Find the directory containing the source code for your version of the application.
  3. Search that directory for the file that describes the user interface (screen contents) for the window you are printing from, usually a .ui file.
  4. Now read the file that describes the behavior for that window, usually a .cpp file with the same main file name as the corresponding .ui file. Look for the sPrint() method and read it carefully, since this is where the parameters get passed to the report. They might be named explicitly or they might be set by other parts of the application that get called from here. In either case, look for uses of a ParameterList variable.

  5. In this case at least one of the parameters is set by calling a method in the WarehouseGroup class -- _warehouse->appendValue(params); -- so we look at the definition of appendValue() there. First we have to change to the directory that contains the WarehouseGroup definition.

  6. Looking at the code for WarehouseGroup we find that if an individual warehouse is selected in the warehouse group then the warehous_id parameter gets set, and that if All Warehouses is selected, the only other alternative in the WarehouseGroup, then the WarehouseGroup does not set any parameters.

  7. Other parameters passed to the report are controlled by the ParameterGroup class -- _classCode->appendValue(params); -- so we look at the definition ofappendValue() there. This method is more complex, and we have to know that we're looking for the parameters relevant to _type == ClassCode.

 1$ svn checkout --username=SOURCEFORGE_USERNAME xtuple
2$ cd postbooks/xtuple/tags/R2_3_2/guiclient
3$ grep "Print Item Labels" *.ui
printItemLabelsByClassCode.ui: <string>Print Item Labels by Class Code</string>
4$ more printItemLabelsByClassCode.cpp
* Common Public Attribution License Version 1.0.
* The contents of this file are subject to the Common Public Attribution

void printItemLabelsByClassCode::sPrint()
q.prepare( "SELECT report_name "
"FROM labelform, report "
"WHERE ( (labelform_id=:labelform_id) "
" AND (report_id=labelform_report_id) );" );
q.bindValue(":labelform_id", _report->id());
if (q.first())
ParameterList params;

orReport report(q.value("report_name").toString(), params);
if (report.isValid())
5$ cd ../widgets
6$ more warehousegroup.cpp
void WarehouseGroup::appendValue(ParameterList &pParams)
if (_selected->isChecked())
pParams.append("warehous_id", _warehouses->id());
7$ more parametergroup.cpp
void ParameterGroup::appendValue(ParameterList &pParams)
if (_selected->isChecked())
if (_type == ClassCode)
pParams.append("classcode_id", _items->id());
else if (_type == PlannerCode)
pParams.append("plancode_id", _items->id());
else if (_type == ProductCategory)
pParams.append("prodcat_id", _items->id());
else if (_type == ItemGroup)
else if (_usePattern->isChecked())
if (_type == ClassCode)
pParams.append("classcode_pattern", _pattern->text());
else if (_type == PlannerCode)
pParams.append("plancode_pattern", _pattern->text());

The end result for this sample problem that the actual report to run is selected from the database based on the form selected via the user interface and that report is passed one of the following combinations of parameters:

  • nothing
  • just "warehous_id"
  • just "classcode_id"
  • just "classcode_pattern"
  • "warehous_id" and "classcode_id"
  • "warehous_id" and "classcode_pattern"

Visit Training.