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

Retrieved the instance(s) of scheduled reports


I am writing a Java command-line program in order to schedule reports (in "right now" mode) in BO XI R2 running on a Windows Server 2003 server.

This program will be launched from an third part scheduler which needs to know the final status of the scheduled report.

My idea is to code an active loop (with sleep) that checks uppon instance status until it is COMPLETED or FAILED.

First, is there another, more elegant way to do it? (maybe using some kind of listener mecanism or something)

Otherwise, how can I retrieve a reference of the instance scheduled using the Schedulable.schedule() method?

I was thinking about using the Schedulable.getLatestInstance() method but there is no garantee that this is REALLY the one that this program has just scheduled, is there?



Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2008 at 01:35 PM

    Very usefull answer, thanks.

    I experienced a difference between scheduling a report from the InfoView and from the SDK:

    When a report is scheduled from InfoView, it goes to the 'RUNNING' status right away but when scheduled from the Java SDK, it stays in the 'PENDING' status for a minute or so before going to the 'RUNNING' status.

    Any idea why?

    Here is a snippet of code I am using (just in case):

    			ISchedulable reportSchedulable = (ISchedulable) infoObject;
    			IInfoObject reportObj = infoObject;
    			ISchedulingInfo reportScheduleInfo = reportSchedulable.getSchedulingInfo();
    			infoObjects = infoStore.query("select top 1 * from CI_SYSTEMOBJECTS where SI_NAME = 'CrystalEnterprise.Managed'");
    			IManaged managed = (IManaged) infoObjects.get(0);
    			IManagedOptions managedOptions = (IManagedOptions) managed.getScheduleOptions();
    			Set destinations = managedOptions.getDestinations();
    			for(int i = 0; i < recipients.length; i++) {
    				infoObjects = infoStore.query("select top 1 * from CI_SYSTEMOBJECTS where SI_KIND = '"+ recipients<i>[0] +"' and SI_NAME = '"+ recipients<i>[1] +"'");
    				IInfoObject userOrGroup = (IInfoObject) infoObjects.get(0);
    				destinations.add(new Integer(userOrGroup.getID()));
    			IDestination managedDestination = reportScheduleInfo.getDestinations().add(managed.getProgID());
    			Object newJobId ="SI_NEW_JOB_ID").getValue();
    			int newJobStatus;
    			String query = "select top 1 * from CI_INFOOBJECTS where SI_ID = '"+ newJobId +"'";
    			boolean loop = true;
    			while(loop) {
    				infoObjects = infoStore.query(query);
    				newJobStatus = ((IInfoObject) infoObjects.get(0)).getSchedulingInfo().getStatus();
    				loop = newJobStatus != ScheduleStatus.COMPLETE && newJobStatus != ScheduleStatus.FAILURE;
    				String statusStr;
    				switch(newJobStatus) {
    				case ScheduleStatus.COMPLETE:
    					statusStr = "COMPLETE";
    				case ScheduleStatus.FAILURE:
    					statusStr = "FAILURE";
    				case ScheduleStatus.PAUSED:
    					statusStr = "PAUSED";
    				case ScheduleStatus.PENDING:
    					statusStr = "PENDING";
    				case ScheduleStatus.RUNNING:
    					statusStr = "RUNNING";
    					statusStr = "UNKOWN";
    				ToolBox.log("La plannification est au statut '"+ statusStr +"'.");
    				if(loop) {

    Add a comment
    10|10000 characters needed characters exceeded

    • I'm assuming your custom app and InfoView are running on different machines.

      Specifically, is InfoView deployed on the same machine as Enterprise, and your custom app on a different machine?

      If so, ensure your clock is synched to Enterprise. We recommend using a time server service.

      If you scheduled right now, it sets the start time for the schedule to the current time of the SDK machine.


      Ted Ueda

  • Posted on Dec 12, 2008 at 10:51 PM

    After you call the Schedule method, you can then reference the Infoobject for the property SI_NEW_JOB_ID. This contains the instance ID of the scheduled job that you can then poll the server for checking for completion.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 01:50 PM

    Yeah, that was it. I am running my program on the server now and scheduled reports and in status 'running' in less than a second.


    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.