Skip to Content

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:

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 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();
  }
  %>

To report this post you need to login first.

8 Comments

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

  1. S man

    Hi..

     

    execution getting fail with below error

     

    org.apache.jasper.JasperException: Unable to compile class for JSP:

     

    An error occurred at line: 12 in the generated java file

    Only a type can be imported. com.crystaldecisions.sdk.occa.report.lib.PropertyBag resolves to a package

    (0) 
    1. Prithviraj Shekhawat Post author

      Error states you do not have the jar file in your application context which contains the above class. However, you can remove ‘com.crystaldecisions.sdk.occa.report.lib.PropertyBag‘ import statement from the code. It is not being used.

       

      I have modified the code as well.

       

      Thanks,

      Prithvi

      (0) 
      1. S man

        Hi,

         

        Really thanks for help.

         

        Now I am able to generate report.

         

        Could you let me know how to right sdk `s.

         

        By any chance do you have document where I can understand how to write SDK??

         

        Really thanks for help

        (0) 
        1. Prithviraj Shekhawat Post author

          Best place to look would be the developers guide and API referrence guide.

          You can find those from

          http://help.sap.com

          Navigate to Analytics–> Business intelligence–> Business intelligence Platform(Enterprise)–> Select the Bo product version and navigate to Development Information.

           

          Thanks,

          Prithvi

          (0) 
  2. Elavarasan P

    Hi,

    I have modified this SDK and try to update new destiantion path for the recurring instances, I am able to update the new destination path and the output is display new path, but it is not updated in the CMS database. Please help me on this and find the below part of modified SDK

     

     

     

      IProperty smtpProps1=(IProperty)smtpProps.getProperty(“SI_PROGID”);

      String smtpProps2=smtpProps1.getValue().toString();

      if (smtpProps2.equals(“CrystalEnterprise.DiskUnmanaged”))

      {                  

        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_OUTPUT_FILES”);

            if(pathProperty4 == null)

          {

              out.println(“No Property with name SI_OUTPUT_FILES<br>”);

          }

          else

          {

         IProperties pathProperties4=(IProperties)pathProperties3.getProperty(“SI_OUTPUT_FILES”).getValue();

           String numberofEmails=pathProperties4.getProperty(“SI_TOTAL”).getValue().toString();

       Integer Emails=new Integer(numberofEmails);

       out.println(“<b>Destination Path :</b><br>”);

       for(int temp=1;temp<=Emails.intValue();temp++)

         {

             String path=pathProperties4.getProperty(“”+temp).getValue().toString();

             out.println(pathProperties4.getProperty(“”+temp).getValue().toString()+”<br>”);

         String repath=path.replace(“servername1″,”servername2”);

         pathProperties4.setProperty(“”+temp, repath);

                String path1=pathProperties4.getProperty(“”+temp).getValue().toString();

                out.print(“New Destination Path: “);

                out.println(pathProperties4.getProperty(“”+temp).getValue().toString()+”<br>”);

              }

            }

          }

        }

      }

     

    Thanks,

    Ela

    (0) 
      1. Dell Stinnett-Christy

        Or, in 4.x, you can just call IInfoObject.save() on the schedule object – it will save a single object to the CMS database, unlike IInfoStore.commit(IInfoObjects) which saves a set of objects to the CMS database.

         

        -Dell

        (0) 

Leave a Reply