cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal report DB connection enabled schedule using JAVA SDK

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Dell,

Thank you for advise..

I will ce

heck my side update the same..

Can you please provide the example also prompts seating for crystal report java sdk..

Regards,

Durga

DellSC
Active Contributor
0 Kudos

There is also sample code for setting parameters in the Wiki I linked to above.  I've attached a couple of .java files from a program that reads data from the database and then creates schedules based on that data.  This is straight Java code, not jsp - I mostly write back-end code.

ParamInfo.java - class for holding info about a specific parameter and its values.

ScheduleConstants.java - constants used in the code.

SetParams Code.txt - the code for setting the parameter values.

-Dell

Answers (0)