Dear Experts,
I have developed a tool with java sdk to schedule the webi reports in BI 4.1, i am facing an issue when scheduling the Crystal report reports when DB connection is enabled .
Please help us the how to schedule the crystal report using SDK when the crystal report is enabled DB connection..
Please find the below source code for scheduling Crystal report.
| | | |
| | |
| | | String reportId = reportDetailsVO.getReport_Id(); |
| | | enterpriseSession = SDKConnectionUtils |
| | | | | .loginToCms(enterpriseSession); |
| | | IInfoStore infoStore = null; |
| | | IInfoObjects oInfoObjects = null; |
| | | String query = "Select TOP 1 * From CI_INFOOBJECTS Where " |
| | | | | + " SI_KIND='CrystalReport' And SI_INSTANCE=0 " |
| | | | | + " And SI_ID = '" + reportId + "'"; |
| | | /* |
| | | * webiReportEngine = (ReportEngine) enterpriseSession |
| | | * .getService("WebiReportEngine"); |
| | | */ |
| | | infoStore = (IInfoStore) enterpriseSession |
| | | | | .getService("InfoStore"); |
| | | oInfoObjects = infoStore.query(query); |
| | | IInfoObject report = (IInfoObject) oInfoObjects.get(0); |
| | | |
| | | Map<String, String> promptAndValues = null; |
| | | promptAndValues = new HashMap<String, String>(); |
| | | if (reportDetailsVO.getReportPromptsNames() != null) { |
| | | | String reportParamNames = reportDetailsVO |
| | | | | | .getReportPromptsNames() + ";"; |
| | | | String[] reportParamNamesArray = reportParamNames |
| | | | | | .split(";"); |
| | | | String reportParamValues = reportDetailsVO |
| | | | | | .getReportPromptsValues() + ";"; |
| | | | String[] reportParamValuesArray = reportParamValues |
| | | | | | .split(";"); |
| | | | for (int i = 0; i < reportParamNamesArray.length |
| | | | | | && reportParamValuesArray[i].length() > 0; i++) { |
| | | | | promptAndValues.put( |
| | | | | | | reportParamNamesArray[i].toString(), |
| | | | | | | reportParamValuesArray[i].toString()); |
| | | /* | | *//** |
| | | * |
| | | * |
| | | p_Monat p_Region p_Filiale |
| | | */ |
| | | /* |
| | | * |
| | | * Map<String, String> promptAndValues = null; promptAndValues = |
| | | * new HashMap<String, String>(); promptAndValues.put("p_Jahr", |
| | | * "2015"); promptAndValues.put("p_Monat", "03"); |
| | | * promptAndValues.put("p_Region", "12"); |
| | | * |
| | | * promptAndValues.put("p_Filiale", "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(); |
| | | | | IReportParameterSingleValue discreteValue = parameterValue |
| | | | | | | .addSingleValue(); |
| | | | | discreteValue.setValue(promptAndValues |
| | | | | | | .get(reportParameter.getParameterName())); |
| | | if (report.getProcessingInfo().properties() != null) { |
| | | | IProperties boProcessingInfo = (IProperties) report |
| | | | | | .getProcessingInfo().properties(); |
| | | | IProperties siPrompts = (IProperties) boProcessingInfo |
| | | | | | .getProperty("SI_PROMPTS").getValue(); |
| | | | int numberPrompts = ((Integer) siPrompts.getProperty( |
| | | | | | "SI_NUM_PROMPTS").getValue()).intValue(); |
| | | | for (int i = 1; i <= numberPrompts; i++) { |
| | | | | try { |
| | | | | | IProperties prompt = (IProperties) siPrompts |
| | | | | | | | .getProperty("SI_PROMPT" + i).getValue(); |
| | | | | | String promptName = prompt.getProperty("SI_NAME") |
| | | | | | | | .getValue().toString(); |
| | | | | | System.out.println("promptName CrystalReport:" |
| | | | | | | | + promptName); |
| | | | | | System.out |
| | | | | | | | .println("promptAndValues.get(promptName):" |
| | | | | | | | | | + promptAndValues.get(promptName)); |
| | | | | } catch (Exception e) { |
| | | | | | e.printStackTrace(); |
| | | | | |
| | | ISchedulingInfo scheduleInfo = report.getSchedulingInfo(); | | |
| | | scheduleInfo.setType(CeScheduleType.ONCE); | | |
| | | scheduleInfo.setRightNow(true); | | |
| | | IReportFormatOptions reportFormatOptions = ((IReport) report) | | |
| | | | | .getReportFormatOptions(); |
| | | reportFormatOptions | | |
| | | | | .setFormat(IReportFormatOptions.CeReportFormat.CRYSTAL_REPORT); |
| | | IInfoObjects objectsToSchedule = infoStore |
| | | | | .newInfoObjectCollection(); |
| | | objectsToSchedule.add(report); |
| | | infoStore.schedule(objectsToSchedule); |
| | | System.out |
| | | | | .println("Instance Generation for crystal called successfully"); Regards, Durga |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.