Strategy ONE
Retrieving a Report Instance
Code sample
This code sample assumes that the reportID is of String datatype. It gets the report instance object of report, whose DSSID is reportID with the following code sample.
1. WebObjectsFactory woFact = WebObjectsFactory.getInstance();
2. WebIServerSession webSS = woFact.getIServerSession();
3. webSS.setServerName("IServer");
4. webSS.setLogin("Administrator");
5. webSS.setProjectName("MyProject");
6. webSS.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
7. WebReportSource reptSrc = woFact.getReportSource();
8. reptSrc.setExecutionFlags(EnumDSSXMLExecutionFlags.DssXmlExecutionUseCache | EnumDSSXMLExecutionFlags.DssXmlExecutionUpdateCache);
9. WebReportInstance rptInst = reptSrc.getNewInstance(reportID);
10. rptInst.setAsync(false);
11. rptInst.setMaxWait(120000);
12. rptInst.setPollingFrequency(250);
13. rptInst.setResultFlags(EnumDSSXMLResultFlags.DssXmlResultGrid);
14. int status = rptInst.pollStatus();
-
Use DssXmlExecutionResolve as the execution flag, if only the sort objects in template are needed. If the report data is not needed, you can avoid building the report in the metadata by using the DssXMLExecutionResolve flag. Using DssXmlExecutionResolve helps to get the report from MicroStrategy Intelligence Server quicker than using other execution flags. However, to see the sorted report data, other flags need to be used.
-
Note that in Line 14, getResults() and getResultsAsXML() is not called for this report instance, since only information about the template is needed and not for the data. If getTemplate() is called immediately after the report instance is obtained, the report instance may not have finished its execution. So, pollStatus() is called to let the server finish the report execution. The return value for this status can be of the following types:
-
Successfully executed, in which case, proceed
-
Requiring prompt resolution, in which case, answer the prompt and proceed
-
Error, in which case, send the error information, and stop
-
