Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting parameters programmatically, saved value of parameter always used


I have downloaded the trial version of Crystal Reports and Crystal Reports Server and created reports which are now in the Repository. The reports have static parameters.

In Eclipse I have set up my development environment, copying C:\Program Files\Business Objects\Common\4.0\crystalreportviewers12 to my WebContent folder, copying jars to the lib directory and editing the web.xml (there are a number of errors in the jsp's due to webreporting.jar not having the CrystalReportInteractiveViewer class, nor the reportsourcebridge.jar).

I now have to set the parameters for the reports programmatically.

I have been using the ReportClientDocument to set parameter values, as discussed by Ted Ueda in his post of March 11 ("How can I set prameters on a report source").

However the report displayed then seems to ignore these parameters and always uses the values the report was first saved with in the repository. Below is the code being used:

ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();

enterpriseSession = sessionMgr.logon(userID, password, CMS, auth);

CrystalReportViewer viewer = new CrystalReportViewer();

int reportId = 1997;

IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");

ReportClientDocument reportClientDoc = reportAppFactory.openDocument(reportId, 0, request.getLocale());

Fields f = reportClientDoc.getDataDefController().getDataDefinition().getParameterFields();

System.out.println("Fields, size: " + f.size() + ", " + f.toString());

ParameterField pField = (ParameterField) f.getField(0);

Values values = new Values();




System.out.println("Fields, size: " + f.size() + ", " + f.toString());

// reportClientDoc.refreshReportDocument();;






viewer.setName("My Simple Employee Report");




viewer.setURI(request.getRequestURI() + "?ReportID=" + reportId);

viewer.processHttpRequest(request, response, getServletContext(), null);


As such I presume I am using the RAS Server. not the Page Server.

When run the report always displays with the values it had when saved in the repository, i.e. the parameter value that I used when I saved the report in the repository is used. I added to "viewer.refresh()", and as a result of this I am prompted to logon to the database. However the current values in the database are not displayed.

Once the report id displayed in the browser, if I then use the viewer in the browser to set and apply a new value for the parameter and click "Apply", then that new parameter value applies and the current values from the database are displayed.

Any help on what I am doing wrong greatly appreciated, I need to have the initial display of the report use a parameter value supplied by the user.






ParameterFieldController parameterFieldController = clientDoc.getDataDefController().getParameterFieldController();

parameterFieldController.setCurrentValue("", ParameterName, ParameterValues);

Hope it will help!



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question