Skip to Content
author's profile photo Former Member
Former Member

Crystal report DB connection enabled schedule using JAVA SDK

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);

// CONTRACT_NUM;

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Aug 16, 2016 at 02:43 PM

    Have you looked at the scheduling sample code that's available here: Java BusinessObjects Enterprise SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki. In particular, you should look at the code for Java_Enterprise_BE115_schedule_report_dblogon

    I know that it's for earlier versions of BO, but, unlike Webi, the Crystal scheduling code hasn't really changed since BO 3.1 unless your reports were written in Crystal for Enterprise, in which case you can use the RESTful Web Services to schedule. However, the RESTful Web Services won't allow you to access parameters and database information for reports that were written in "classic" Crystal (Crystal 2011, 2013, 2016, etc.)

    -Dell

    Message was edited by: Dell Stinnett-Christy

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.