Advanced Customization > Business Logic Customization > Report Generation > Launching Reports from Custom Windchill Pages
Launching Reports from Custom Windchill Pages
The following are the two ways to execute the report:
Through Windchill UI action
By invoking Java service API
Executing Report Through Windchill UI Action
1. Create an Action and Action Model in Windchill as per your requirement and click on Action to open the JSP page.
* 
For more information, see Defining a New Action and Defining a New Action Model.
2. Create a JSP file.
3. Add TLD file dependency. For example,
<%@taglib uri="http://www.ptc.com/windchill/taglib/executeReport" prefix="Report"%>
4. Create a HashMap to send request criteria parameters and add values as per your report requirement. For example,
<%
HashMap reportCriteriaMap = new HashMap<String, Object>();
reportCriteriaMap.put("IDA2A2", "7940920");
%>
5. Pass the HashMap reportParamMap="<%= reportCriteriaMap%>" to TLD file for further processing. For example,
<Report:executeReport reportParamMap="<%=reportCriteriaMap%>" />
6. Execute the JSP file with report object identifier to generate the report. For example,
http://vagrant.ptcnet.ptc.com:2280/Windchill/netmarkets/jsp/report/xyz.jsp?oid=com.ptc.windchill.enterprise.report.Report:198531
* 
The query parameter must be a Report Oid.
Executing Report Through Supported API
* 
The following method shall be used only to execute report in read form. It must not be used for modification of report.
1. The following four parameters of service API are exposed for executing report in reporting module.
WTReference of Windchill report object (com.ptc.windchill.enterprise.report.Report.java).
Map send request criteria parameters as per your report requirement. For example,
Map<String, String> reportCriteriaMap = new HashMap<String, String>();
reportCriteriaMap.put("IDA2A2", “1234”);
Report format type.
* 
ReportFormatType enum is used in ReportServiceHelper.executeThirdPartyReport(). It passes index value to ReportServiceHelper.executeThirdPartyReport().
For example, use the following report format type:
(ReportFormatType.REP_HTML, ReportFormatType.REP_XML,
ReportFormatType.REP_PDF, ReportFormatType.REP_CSV,
ReportFormatType.REP_EXCEL)
File output stream.
* 
This object must be closed by a stream creator. ReportServiceHelper.executeReport () method will not close output stream object.
2. Use the above four parameters to call the following method:
ReportServiceHelper.executeReport (WTReference reference, Map params, ReportFormatType reportFormatType, OutputStream output)
3. Launch the report using the file output stream.
For reports based on Windchill Report Templates, you need to add the following parameters to execute the report.
* 
The following parameters are specified as constants in com.ptc.windchill.enterprise.report.ReportServiceHelper.java class.
Parameter Name
Description
FORMAT
To specify the format of the generated report.
Specify FORMAT_DELEGATE to generate the report in delegated format.
DELEGATE_NAME
To specify the name of the delegated format.
Specify PDF to generate report in PDF format.
Specify XML to generate report in XML format.
Specify CSV to generate report in CSV format.
Specify HTML_WITH_SORTING to generate report in HTML format with sorting.
Specify HTML_WITH_MERGING to generate report in HTML format with merging.
Specify HTML_WITH_SORTING_AND_MERGING to generate report in HTML format with sorting and merging.
SORT_ORDER
To specify the sort order of the generated report.
Specify SORT_ASCENDING to sort report in ascending order.
Specify SORT_DESCENDING to sort report in descending order.
SORT_BY_INDEX
To specify the sort order of the generated report by column index.
IGNORE_CUSTOM_INPUT_PAGE
Specify true to ignore custom input page.
Specify false to view custom input page.
Example 1
If you want to execute report for CSV type then add the following parameters:
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(ReportServiceHelper.DELEGATE_NAME , ReportServiceHelper.CSV);
parameters.put(ReportServiceHelper.FORMAT , ReportServiceHelper.FORMAT_DELEGATE);
parameters.put(ReportServiceHelper.IGNORE_CUSTOM_INPUT_PAGE, “true”);
Example 2
If you want to execute report in sorted order then add the following parameters:
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(ReportServiceHelper.DELEGATE_NAME, ReportServiceHelper.HTML_WITH_SORTING_AND_MERGING);
parameters.put(ReportServiceHelper.FORMAT, ReportServiceHelper.FORMAT_DELEGATE);
parameters.put(SORT_ORDER, SORT_ASCENDING);
parameters.put(SORT_BY_INDEX, "2"); // Sort by column index
Was this helpful?