cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieved the instance(s) of scheduled reports

Former Member
0 Kudos

Hello

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?

Thanks

Guillaume

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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();
			reportScheduleInfo.setType(CeScheduleType.ONCE);
			reportScheduleInfo.setRightNow(true);

			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();
			
			managedOptions.setDestinationOption(IManagedOptions.CeDestinationOption.ceInbox);
			managedOptions.setSendOption(IManagedOptions.CeManagedSendOption.ceCopy);
			
			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());
			managedDestination.setFromPlugin(managed);

			infoStore.schedule(reports);

			Object newJobId = reportObj.properties().getProperty("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";
					break;
				case ScheduleStatus.FAILURE:
					statusStr = "FAILURE";
					break;
				case ScheduleStatus.PAUSED:
					statusStr = "PAUSED";
					break;
				case ScheduleStatus.PENDING:
					statusStr = "PENDING";
					break;
				case ScheduleStatus.RUNNING:
					statusStr = "RUNNING";
					break;
				default:
					statusStr = "UNKOWN";
				};
				ToolBox.log("La plannification est au statut '"+ statusStr +"'.");
				if(loop) {
					Thread.sleep(1000);
				}
			}

			session.logoff();

ted_ueda
Employee
Employee
0 Kudos

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.

Sincerely,

Ted Ueda

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Thanks!

Adam_Stone
Active Contributor
0 Kudos

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.