EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB34506: How to run a report and return the number of rows using the MicroStrategy Web API 9.4.1


Community Admin

• Strategy


The example provided in this document is provided “as-is” to the user and assumes that the user:

  • Can program, compile (e.g. javac, jikes, etc.), and execute Java programs
  • Can configure environment variables (e.g. JAR files, property files, etc.)
  • Have all the necessary tools to create Java applications (JDK, IDE, etc.)
  • Has access to the Strategy SDK documentation.
  • Has read the customization warning at the bottom of this document

 
PREREQUISITES:
For the sample to work, the Strategy Web JAR files must be accessible by the Java Runtime
Environment. The Strategy Web JAR files can be found under:

  • Strategy Web Universal (JSP): {web_root}/WEB-INF/lib directory.
  • Strategy Web (.NET): Program Files\Common Files\Strategy directory.

Note:
More elaborate programs will require additional library files and are out of the scope of this document.
 
The following code snippet shows how to create a report instance and get the number of rows returned by the Intelligence Server after executing the report:
 


package com.Strategy.standalone;

import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebReportData;
import com.Strategy.web.objects.WebReportGrid;
import com.Strategy.web.objects.WebReportSource;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebReportInstance;

public class ReportExecutionSample {
    public static void displayReportXML() {
        WebIServerSession serverSession = null;
        WebReportSource reptsrc=null; 

        //Create a session using the SessionManagementSample class
        serverSession = SessionManagementSample.getSession();

        //Create Report Source
        reptsrc=serverSession.getFactory().getReportSource();

        //ID of report to execute 
        String reportID = "C7184E1E44BD87E994EEDCA703CC5F93";
        //Get new Report Instance

        WebReportInstance reportInstance=null;
        try {
            reportInstance=reptsrc.getNewInstance(reportID);

        } catch (WebObjectsException ex) {} 
        reportInstance.setAsync(false);

        //Get report Grid and execute report instance
        WebReportGrid reportGrid=null;
        try {
            WebReportData reportData=reportInstance.getResults();
            System.out.println(reportData.getGridTotalRows());
            reportGrid=reportData.getWebReportGrid();
        } catch (WebObjectsException ex) {}

        //Close session
        SessionManagementSample.closeSession(serverSession);
    }

    public static void main(String args[]) {
        displayReportXML();
    }

}

 

 


Comment

0 comments

Details

Knowledge Article

Published:

June 22, 2017

Last Updated:

June 22, 2017