Hi developers/experts - Am trying to Schedule Crystal Reports Using SAP SDKs, but am facing some challenges while passing parameter Type (Date, Number or String). So am looking for some advice and guidance to pass the parameters. Am using CrystalReportSDK-4.2.jar
Currently We are using only String as a Parameter for most of the Reports, below is the Code snippet. In BO, the report parameters Type is a String, so no issues while scheduling.
IInfoObjects oInfoObjects = null; String query = "Select TOP 1 * From CI_INFOOBJECTS Where SI_KIND='CrystalReport' And SI_INSTANCE=0 And SI_ID =104436"; infoStore = (IInfoStore) enterpriseSession .getService("InfoStore"); oInfoObjects = infoStore.query(query); IReport report = (IReport) oInfoObjects.get(0); for (int i = 0; i < ((IReport) report).getReportParameters() .size(); i++) { IReportParameter reportParameter = (IReportParameter) ((IReport) report) .getReportParameters().get(i); if (reportParameter.isDiscreteValueSupported()) { IReportParameterValues parameterValue = reportParameter.getCurrentValues(); parameterValue.setNoValue(true); IReportParameterSingleValue discreteValue = parameterValue.addSingleValue(); discreteValue.setValue("some value"); }} ISchedulingInfo schedInfo = report.getSchedulingInfo(); schedInfo.setRightNow(true); schedInfo.setType(CeScheduleType.ONCE); infoStore.schedule(oInfoObjects);
IReport newReport = (IReport) oInfoObjects.get(0);
But the real Challenge is for reports which is created with Parameter Types a (Date, Number, String or Currency). So am assuming that using IParameterFieldDiscreteValue would resolve that but actually not !!!!. I tried like this
for (int i = 0; i < ((IReport)report).getReportParameters().size(); i++) { IReportParameter reportParameter = (IReportParameter)((IReport)report).getReportParameters().get(i); IReportParameterValues parameterValue = reportParameter.getCurrentValues(); if (reportParameter.isDiscreteValueSupported() && reportParameter .getValueType() == IReportParameter.ReportVariableValueType.STRING) { IParameterFieldDiscreteValue discreteValue = (IParameterFieldDiscreteValue)parameterValue.getValues(3).getValue(0); discreteValue.setValue("A String"); ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue(); pfieldDV1.setValue(""); } else if (reportParameter.isDiscreteValueSupported() && reportParameter .getValueType() == IReportParameter.ReportVariableValueType.DATE) { IParameterFieldDiscreteValue discreteValue = (IParameterFieldDiscreteValue)parameterValue.getValues(6).getValue(0); discreteValue.setValue(new DateConversion()); }else if (reportParameter.isDiscreteValueSupported() && reportParameter .getValueType() == IReportParameter.ReportVariableValueType.NUMBER) { IParameterFieldDiscreteValue discreteValue = (IParameterFieldDiscreteValue) parameterValue.getValues(0).getValue(0); discreteValue.setValue(9); } }
If any one faced this situation, please share your thoughs and approach to handle this!!!