Setting BCA schedule time through Java SDK.

Gurus,
I am new to Java programming, please help.
I am trying to automate the scheduling of BO reports through a Java program running on Solaris server that fetches the report from Corporate Documents, populates the prompts and submits to BCA after setting the scheduling options. I got a lot of useful code from this forum and was able to get my program to perform all tasks… almost.
For some reason, BCA doesnt set the schedule property for Start Time of report and the reports always start instantly. Here is a piece of code that I am using to set the Scheduling properties and trying to start the reports 10 minutes after sysdate :
//***********Problem code Start
//Set Scheduling options

	  schedulingOption = webiDoc.getSchedulingOption();    
  schedulingOption.setSchedulerName(rptSchedulerName);
  schedulingOption.setStartDate(dtStart); 
  schedulingOption.setExpirationDate(dtEnd);
             schedulingOption.setScheduleMode(WIScheduleMode.wiOnce); 
  schedulingOption.setRefreshInTheNameOfRecipient(true);
  webiOnce = schedulingOption.getOnce();

              cal.add(Calendar.MINUTE,10);	
 dtOnce = dtFormat.parse(cal.get(Calendar.DAY_OF_MONTH) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR) + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));
          System.out.println("dtOnce is set to : "+dtOnce);
          webiOnce.setStartTime(dtOnce);
          schedulingOption.setScheduleMode(WIScheduleMode.wiOnce);   
          webiDoc.send(strCDSId,repdomain,true,strSendTo);  

//*********Problem code End
Am I doing something wrong or missing something here?
Anyone run into similar issues?

Appreciate your help.
Thanks,
Rahul Pradhan.


rahulpradhan (BOB member since 2002-08-21)

What is it seting the start time to. Not familiar with the java sdk but in the vb sdk, if you don’t set the time correctly in your code, the bca will assume 12am and thusly run the report right away if start date is today.


cparsons :us: (BOB member since 2004-02-20)

The start time is in BCA console is displayed as current time and so the report starts right away. In the code I am setting the start time to be 10 minutes from now, but it gets ignored. I even tried changing the day but BCA always starts the report immediately.


rahulpradhan (BOB member since 2002-08-21)

webiOnce.setStartTime(dtOnce); 
schedulingOption.setScheduleMode(WIScheduleMode.wiOnce); 
webiDoc.send(strCDSId,repdomain,true,strSendTo); 
//*********Problem code End

Not to familiar with the java object model but first thing that jumps out at me is you are setting parameters for webiOnce and then sending webiDoc. Probalbly as much insight as I can give. If that helps at all.


cparsons :us: (BOB member since 2004-02-20)

Hi Rahul,

    I am also trying to schedule a document with prompts using java SDK, but it is not scheduling the document. I get the following exception

WebIntelligence SDK / JSP Exception — Number :10451 — javaError : Internal W
I ErrCode=2 — Description : Error scheduling document
com.bo.wibean.WIException: WebIntelligence SDK / JSP Exception — Number :10451
— javaError : Internal WI ErrCode=2 — Description : Error scheduling docume
nt
at com.bo.wibean.WIDocumentImpl.schedule(WIDocumentImpl.java:2913)
at com.bo.wibean.WIDocumentImpl.export(WIDocumentImpl.java:354)
at com.bo.wibean.WIDocumentImpl.send(WIDocumentImpl.java:1987)
at com.sabre.apd.mda.common.ReportGenerator.scheduleReport(ReportGenerat
or.java:237)
at com.sabre.apd.mda.common.ReportGenerator.getReport(ReportGenerator.ja
va:183)

Here’s my code…

private static void scheduleReport(WIDocument webiDocument, Vector prompts)
{
    try
    {
        WIScheduler scheduler = webiDocument.getContext().openSchedulers().getItem(2);
WIPrompts webiPromptList = webiDocument.getPromptsEx();

                    int numberOfPrompts = webiPromptList.getCount();

                    for (int i = 1; i <= numberOfPrompts; i++)
                    {
                        WIPrompt webiPrompt = webiPromptList.getItem(i);
                        webiPrompt.getListOfValues(false); 
                      if (webiPrompt.getType() == WIPrompt.ENTERVALUE)
                        {

                            webiPrompt.enterValue((String) prompts.elementAt(i - 1));
                        }
                    }
        webiDocument.setPromptsEx();

        WISchedulingOption schedulingOption = webiDocument.getSchedulingOption();
        schedulingOption.setSchedulerName(scheduler.getName());
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssZ");
        sdf.setLenient(false);
        Date dt1 = sdf.parse("050309013000-0700");
        Date dt2 = sdf.parse("050309023000-0700");
        schedulingOption.setStartDate(dt1);
        schedulingOption.setExpirationDate(dt2);
        schedulingOption.setScheduleMode(WIScheduleMode.wiOnce);
        schedulingOption.getOnce().setStartTime(dt1);
        WIRecordset scheduledJobs = scheduler.getJobList();
        String[] userList = new String[1];
        userList[0] = "sg0417735_p";

        webiDocument.send(MdaDefinitions.TOPMARKETSGLOBAL, "MDA",false,userList);
        System.out.println("# scheduled jobs = " + scheduledJobs.getRecordCount() );
        WIXLSView xlsView = webiDocument.getXLSView();
    }
    catch(WIException e)
    {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
}

It’s throwing an exception at the line

        webiDocument.send(MdaDefinitions.TOPMARKETSGLOBAL, "MDA",false,userList);

Am I missing something ? Your help will be greatly appreciated.

thanks,
PC


pc (BOB member since 2005-03-02)

Hi,
I am also getting the same error. Could you able to resolve the issue. Can you please let me know, what was the solution for this problem.

advance thanks for your help.

Vijay


vijayabaskar (BOB member since 2007-01-02)