This document provides a way get the failed instance information using the BusinessObjects Enterprise Platform Java SDKs.

For more scripts and information on how to run these scripts refer to the blog avaiable here:

http://scn.sap.com/people/shawn.penner/blog/2013/06/04/scripts-and-samples

Below is the Java Server Pages (JSP) sample

Notes:

•You would need to change the userName, password, cmsName to the values specific to your enterprise server in the provided sample code.

Get Failed Instance Information

<%@ page import=”com.crystaldecisions.sdk.plugin.desktop.program.*,
    com.crystaldecisions.sdk.framework.*,
    com.crystaldecisions.sdk.occa.infostore.*,
    com.crystaldecisions.sdk.exception.*,
     java.io.FileWriter, java.io.IOException,
    com.crystaldecisions.sdk.occa.report.lib.PropertyBag,
    com.crystaldecisions.sdk.properties.IProperties,
    com.crystaldecisions.sdk.properties.IProperty,
    java.util.*”
%>
<%

  
   String user = “Administrator”;
   String password = “<Administrator-Password>”;        
   String cmsName = “<CMS-NAME>”;        
   String cmsAuthType = “secEnterprise”;
   String starttime=null;
   String endtime=null;
   String retriesAttempted=null;
 
  IEnterpriseSession es=null;
 
  try
  {
   String statusCheck=null;
   String typeCheck=null;
   es = CrystalEnterprise.getSessionMgr().logon( user, password, cmsName, cmsAuthType);                
   IInfoStore iStore = (IInfoStore) es.getService(“”, “InfoStore”);                
   IInfoObjects infoobjects = iStore .query(“SELECT * from CI_INFOOBJECTS WHERE  si_instance=1 and si_schedule_status=3”);                
 
   for(int i=0;i<infoobjects.size();i++)
   {
    IInfoObject infoobject=(IInfoObject) infoobjects.get(i);
    ISchedulingInfo schedInfo=infoobject.getSchedulingInfo();
    int instanceID=infoobject.getID();
    String instanceName=infoobject.getTitle();
    String errorMsg=schedInfo.getErrorMessage();
    out.println(“<b>Instance ID :</b>”+instanceID+”<br>”);
    out.println(“<b>Instance Name :</b>”+instanceName+”<br>”);
    int type=schedInfo.getType();
    out.println(“<br><b> Type of the report :</b><br>”);
 
    switch(type)
    {
     case CeScheduleType.ONCE:
     typeCheck=”ONCE”;
     out.println(typeCheck);
    
     break;
        
     case CeScheduleType.HOURLY: //Job has failed.
     typeCheck=”HOURLY”;
     out.println(typeCheck);
    
     break;
       
     case CeScheduleType.DAILY: //Job is paused.
     typeCheck=”DAILY”;
     out.println(typeCheck);
     break;
       
     case CeScheduleType.WEEKLY: //Job is pending.
     typeCheck=”WEEKLY”;
     out.println(typeCheck);
     break;
       
     case CeScheduleType.MONTHLY: //Job is running.
     typeCheck=”MONTHLY”;
     out.println(typeCheck);
     break;
    
     case CeScheduleType.NTH_DAY:
     typeCheck=”NTH_DAY”;
     out.println(typeCheck);
    
     break;
        
     case CeScheduleType.FIRST_MONDAY: //Job has failed.
     typeCheck=”FIRST_MONDAY”;
     out.println(typeCheck);
     break;
       
     case CeScheduleType.LAST_DAY: //Job is paused.
     typeCheck=”LAST_DAY”;
     out.println(typeCheck);
     break;
       
     case CeScheduleType.CALENDAR: //Job is pending.
     typeCheck=”CALENDAR”;
     out.println(typeCheck);
     break;
       
     case CeScheduleType.CALENDAR_TEMPLATE: //Job is running.
     typeCheck=”CALENDAR_TEMPLATE”;
     out.println(typeCheck);
     break;
    }
   
 
    IProperties instanceProperties=(IProperties)infoobject.properties();
    IProperty instanceProperty=instanceProperties.getProperty(“SI_STARTTIME”);
    if(instanceProperty != null)
    {
    starttime=instanceProperty.getValue().toString();
    out.println(“<br><b>Instance Start Time :</b>”+starttime+”<br>”);
    }
    IProperties instanceProperties1=(IProperties)infoobject.properties();
    IProperty instanceProperty1=instanceProperties1.getProperty(“SI_ENDTIME”);
    if(instanceProperty1 != null)
    {
 
    endtime=instanceProperty1.getValue().toString();
    out.println(“<br><b>Instance End Time :</b>”+endtime+”<br>”);
    }
    IProperties instanceProperties2=(IProperties)infoobject.getSchedulingInfo().properties();
    IProperty instanceProperty2=instanceProperties2.getProperty(“SI_RETRIES_ATTEMPTED”);
    if(instanceProperty2 != null)
    {
 
    retriesAttempted=instanceProperty2.getValue().toString();
 
    out.println(“<br><b>Retries Attemted :</b>”+retriesAttempted+”<br>”);
    }
    out.println(“<b>Error Message :</b>”+errorMsg+”<br>”);
                 
    out.println(“<br>====================================================================<br>”);  
           
   }
  }
      catch(SDKException e)
  {
    out.println(e.getMessage());
  }
  finally
  {
  es.logoff();
  }
%>

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Lokesh Borse

    Hi Prithvi,

    I am trying to execute this script for Xi 3.1. I put this jsp to InfoViewApp folder and trying to run but it returned error:

    “Unable to compile class for JSP Generated servlet error: Only a type can be imported. com.crystaldecisions.sdk.occa.report.lib.PropertyBag resolves to a package “

    Please suggest

    (0) 
        1. Prithviraj Shekhawat Post author

          Remove below from code to remove retries attempted

          IProperties instanceProperties2=(IProperties)infoobject.getSchedulingInfo().properties();

              IProperty instanceProperty2=instanceProperties2.getProperty(“SI_RETRIES_ATTEMPTED”);

              if(instanceProperty2 != null)

              {

           

              retriesAttempted=instanceProperty2.getValue().toString();

           

              out.println(“<br><b>Retries Attemted :</b>”+retriesAttempted+”<br>”);

              }

          Type is the schedule type for the instance. Match the results from query builder

          (0) 

Leave a Reply