The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Jasper Reports with PPM

SOLVED
Go to solution
Highlighted
Syed Abdul Sama
Acclaimed Contributor

How to use Jasper Reports with PPM

Dear all,

I am new to PPM, but i have expertise in J2EE and Jasper Reports.

If any one of you have used Jasper Reports with PPM, could you please tell me how you do
that.

I will be really really thankful of you.
8 REPLIES
Mahen M
Honored Contributor
Solution

Re: How to use Jasper Reports with PPM

I have never heard of Jasper Reports with PPM,

We can import Java and WSRP Portlet Definitions. We cannot create custom Java and Custom WSRP Portlet.

Please raise a case with HP regarding Jasper Reports.

Thank you

Regards,
Mahendran M
Syed Abdul Sama
Acclaimed Contributor

Re: How to use Jasper Reports with PPM

According to my knowledge for creating
new reports in PPM many people in industry are using Jasper and Birt with PPM.

And I have seen posts in this forum where
people mentioned that they are using those
3rd party reporting engines.
Mahen M
Honored Contributor

Re: How to use Jasper Reports with PPM

The Jasper and Birt are sounding like Greek and Latin to me, I am sorry.

We are using SQL Server 2005 Datawarehouse.... I am sorry, I have limited knowledge.

Regards,
Mahendran M
Sandeep K
Super Collector

Re: How to use Jasper Reports with PPM

Syed,

You will have to do more research but the over all approach would be to create a custom ppm report, a JSP that calls the jasper report and the jasper report itself of course.
And you still will be able to use its scheduling feature.
Sascha Mohr
Esteemed Contributor

Re: How to use Jasper Reports with PPM

He's right, that is exactly what we did. It is completely transparent for the users and they benefit from PDF-Reports that can be printed in high quality.
If you have questions to the details I may be able to help.
Sandeep K
Super Collector

Re: How to use Jasper Reports with PPM

Well Sascha, I actually need help !
Could you post any details.
Syed Abdul Sama
Acclaimed Contributor

Re: How to use Jasper Reports with PPM

thanks guys,,,, i have already started working on BIRT with PPM for custom reports, and its working fine......

thanks & regards,

Syed Abdul Samad
Sascha Mohr
Esteemed Contributor

Re: How to use Jasper Reports with PPM

Sure, first you need to build the JasperReports JAR with ANT and put it in \deploy\itg.war\WEB-INF\lib
Unfortunately I cannot help you with that, as I have never done this myself.

Then you would create PPM report types that call custom JSPs like this:

ksc_run_jsp_report /web/knta/rpt/jasper/projektliste.jsp
REPORT_ID=[RP.REPORT_SUBMISSION_ID]
USER_ID=[RP.CREATED_BY]
ksc_end_report_parameters

You can have additional parameters/filters as you need of course.
The projektliste.jsp in this example has 4 of them; it's source could look like this:
===============================================================================
<%@ page language="java" contentType="application/pdf; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="de.custom.itg.JRReportGenerator" %>
<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.kintana.core.logging.*" %>
<%@ page import="com.kintana.core.db.DBSession" %>
<%@ page import="java.io.FileOutputStream" %>
<%@ page import="com.kintana.core.util.DateFormatter" %>
<%@ taglib uri="/Kintanareporttld" prefix="rpt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>



<meta http-equiv="Content-Type" content="application/pdf; charset=ISO-8859-1" />
<script type="text/javascript">
function ReportWindow () {
Report = window.open("/web/knta/rpt/jasper/show.jsp", "Report", "menubars=yes");
Report.focus();
}
</script>







<%-- set used parameters to request scope, so that they can be accessed in java --%>





<%
Logger logger = LogManager.getLogger( "com.kintana.rpt.tag" );

// set file information to load
String filename = "Projektliste";
String path = "/web/knta/rpt/jasper/";
String completeName = path + filename + ".jrxml";
FileInputStream inputStream = new FileInputStream(application.getRealPath(completeName));
logger.info("loaded file: " + application.getRealPath(completeName));

// get DB connection from pageContext (set by rpt:getJDBCConnection)
DBSession dbsession = (DBSession) pageContext.getAttribute("RPT_DATA_SRC" , 2);
Connection conn = dbsession.getConnection();

// add all parameters for report to map, they were added to request above
Map map = new HashMap();
map.put("userID", request.getAttribute("userID"));
map.put("LAENDER", request.getAttribute("countries"));
map.put("THEMA", request.getAttribute("themen"));
map.put("RESSORT", request.getAttribute("ressort"));
map.put( "imagePath", application.getRealPath( "/web/knta/rpt/jasper/images" ) );

// generate pdf output
JRReportGenerator gen = new JRReportGenerator();
byte[] output = gen.createPDFReport(inputStream, conn, map);
conn.close();
if (output != null) {
// create a specific filename for saving exported pdf
java.util.Date now = new java.util.Date();
String formatted = DateFormatter.formatDateTime( pageContext, now, " yyyy-MM-dd hh-mm-ss", "" );
String expname = filename + formatted + ".pdf";

String expPath = "/web/knta/rpt/jasper/";
String export = application.getRealPath(expPath + expname);
FileOutputStream outStream = new FileOutputStream(export);
outStream.write( output );
outStream.close();

%>
<%-- set exported file information to application, so that show.jsp knows what file to use --%>

<%
}
inputStream.close();
%>
<script Language="javascript">
ReportWindow();
setTimeout("self.close();", 500);
</script>



===============================================================================
It generates the report using the database connection of PPM, so you don't need to deal with that.
After the report is generated it opens "show.jsp" in a new windows (deactivate pop-up blockers!).
show.jsp is fairly simple then:
===============================================================================
<%@ page language="java" contentType="application/pdf; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.ByteArrayOutputStream" %>
<%@ page import="com.kintana.core.logging.*" %>
<%
Logger logger = LogManager.getLogger( "com.kintana.rpt.tag" );

String expname = (String) application.getAttribute("exportName");
logger.info("pdf file to load: " + expname);
FileInputStream input = new FileInputStream(expname);
out.clear();
out = pageContext.pushBody();
response.reset();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[16384];
for (int len = input.read(buffer); len > 0; len = input.read(buffer)) {
baos.write(buffer, 0, len);
}
baos.writeTo(response.getOutputStream());
input.close();
%>
===============================================================================
Designing the reports themselves is fairly straight forward, just be sure to include the parameters you define in the PPM report definition in the JRXML report definition as well (in the SQL and as parameter items in the list).
I hope, this will help you.
Regards
Sascha
//Add this to "OnDomLoad" event