Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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

The recurring instance details include Instance ID, Instance Name, Instance Kind, Schedule Type, Folder Location, Next Runtime and Destination


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

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 Rucurring 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.properties.IProperties,
com.crystaldecisions.sdk.properties.IProperty,

com.crystaldecisions.sdk.plugin.desktop.folder.*,
java.util.*,
java.text.*"
%>
<%@ page import="java.io.*" %>

<%


  
        String user = "Administrator";
     String password = "";        
  String cmsName = "localhost:6400";        
  String cmsAuthType = "secEnterprise";
  String nextruntime=null;
  String retriesAttempted=null;
  String finalFolderPath=null;
  Date convertedDate=null;

  IEnterpriseSession es=null;
  int index = 1;
 
  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_recurring=1 ");           
 
   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 kind=infoobject.getKind();
    out.println("<b>Instance ID :</b>"+instanceID+"<br>");
    out.println("<b>Instance Name :</b>"+instanceName+"<br>");
    out.println("<b>Kind :</b>"+kind+"<br>");
    int type=schedInfo.getType();
    out.println("<br><b> Schedule Type :</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;
    }
   
  int id=infoobject.getParentID();

  IInfoObjects infoobjects1 = iStore .query("SELECT * from CI_INFOOBJECTS WHERE  si_id="+id);

  IInfoObject infoobject1=(IInfoObject)infoobjects1.get(0);

  String reportName=infoobject1.getTitle();
 
  int parentid=infoobject1.getParentID();
 
 
  IInfoObjects infoobjects2 = iStore .query("SELECT * from CI_INFOOBJECTS WHERE  si_id="+parentid);

  IInfoObject infoobject2=(IInfoObject)infoobjects2.get(0);
  if(infoobject2.getKind().equals("Folder"))
  {
    finalFolderPath="/";
   IFolder iifolder=(IFolder)infoobject2;
   if(iifolder.getPath()!= null)
   {
    String path[]=iifolder.getPath();
    for(int fi=0;fi<path.length;fi++)
    {
     finalFolderPath =  "/"+path[fi]+ finalFolderPath;
 
    }
     finalFolderPath = finalFolderPath+iifolder.getTitle();
   }
   else
   {
    finalFolderPath=finalFolderPath+iifolder.getTitle();
   }
   out.println("<br><b>Parent Folder Path of The Report :</b>"+finalFolderPath+"<br>");
  
  }
 
  IProperties instanceProperties=(IProperties)infoobject.properties();
  IProperty instanceProperty=instanceProperties.getProperty("SI_NEXTRUNTIME");
    if(instanceProperty != null)
    {

    nextruntime=instanceProperty.getValue().toString();
    out.println("<br><b>Instance Next Run Time :</b>"+nextruntime+"<br>");
   
 
    DateFormat readFormat=new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
 
    convertedDate=readFormat.parse(nextruntime);
    out.println("Next Run Time Converted To Date :"+convertedDate+"<br>");
    }
  IProperties destinationProperties=(IProperties)infoobject.getSchedulingInfo().properties();
  IProperties destinationProperty=(IProperties)destinationProperties.getProperties("SI_DESTINATIONS");
 
  if(destinationProperty == null)
  {
  out.println("No Property with SI_DESTINATIONS<br>");
  }
  else
  {
  IProperties smtpProps=(IProperties)destinationProperty.getProperties("1");
 
  if(smtpProps != null)
  {
  IProperty smtpProps1=(IProperty)smtpProps.getProperty("SI_PROGID");
  String smtpProps2=smtpProps1.getValue().toString();
  if (smtpProps2.equals("CrystalEnterprise.Smtp"))
   {                  
              
                IProperties pathProperties1=(IProperties)schedInfo.properties().getProperty("SI_DESTINATIONS").getValue();

                             
    IProperty pathProperty2=pathProperties1.getProperty("1");
   
    if(pathProperty2 == null)
    {
     out.println("No Property with name 1<br>");
    }
    else
    {
   
     IProperties pathProperties2=(IProperties)pathProperties1.getProperty("1").getValue();
     IProperty pathProperty3=pathProperties2.getProperty("SI_DEST_SCHEDULEOPTIONS");
    
     if(pathProperty3 == null)
     {
      out.println("No Property with name SI_DEST_SCHEDULEOPTIONS<br>");
     }
     else
     {
      IProperties pathProperties3=(IProperties)pathProperties2.getProperty("SI_DEST_SCHEDULEOPTIONS").getValue();
     
      IProperty pathProperty4=pathProperties3.getProperty("SI_MAIL_ADDRESSES");
     
      if(pathProperty4 == null)
      {
       out.println("No Property with name SI_MAIL_ADDRESSES<br>");
      }
      else
      {
     IProperties pathProperties4=(IProperties)pathProperties3.getProperty("SI_MAIL_ADDRESSES").getValue();
     IProperty pathProperty5=pathProperties3.getProperty("SI_MAIL_CC");
     
      if(pathProperty5 == null)
      {
       out.println("No Property with name SI_MAIL_ADDRESSES<br>");
      }
      else
      {
    
    IProperties pathProperties5=(IProperties)pathProperties3.getProperty("SI_MAIL_CC").getValue();

    String numberofEmails=pathProperties4.getProperty("SI_TOTAL").getValue().toString();
    String numberofCCEmails=pathProperties5.getProperty("SI_TOTAL").getValue().toString();

    
   
    
                                          
         Integer Emails=new Integer(numberofEmails);
    out.println("<b>Email Address :</b><br>");                                                             
    for(int temp=1;temp<=Emails.intValue();temp++)
    {
     String email=pathProperties4.getProperty(""+temp).getValue().toString();
     out.println(pathProperties4.getProperty(""+temp).getValue().toString()+"<br>");
        }
                 
    Integer CCEmails=new Integer(numberofCCEmails);
    out.println("<b>CC Email Address :</b><br>");                                                             
    for(int temp1=1;temp1<=CCEmails.intValue();temp1++)
    {
     String CCemail=pathProperties5.getProperty(""+temp1).getValue().toString();
     out.println(pathProperties5.getProperty(""+temp1).getValue().toString()+"<br>");
                } 
      }
   
      }
   }
   }
   }
  
  else
      {
   out.println("Not Applicable For This Instance....!<br>");
      }
   }
        }
     out.println("<br>===========================================================<br>");
     }
     }
     catch(SDKException e)
  {
    out.println(e.getMessage());
  }
  finally
  {
  es.logoff();
  }
  %>

8 Comments
Labels in this area