cancel
Showing results for 
Search instead for 
Did you mean: 

Instance manager like output code modification

Former Member
0 Kudos

Dear Experts,

I have a two jsp codes where it produces a tabular webpage output similar to Instance manager.

1. I would like to add Error Message to the code, I guess getErrorMessage() gives but not sure how to add it in the code.

2. When the Folder Path is null the adjacent column data is moved left.

3. Is it possible to run this code as a program object and schedule using CMC?

Code-1

------------------------

<%@ 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.*,

java.io.*"

%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>

<html>

<head></head>

<body>

<table border="2" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">

<tr>

  <th width="10%"> Id</th>

  <th width="20%"> Title</th>

  <th width="10%"> Type</th>

  <th width="10%"> Status</th>

  <th width="30%">Folder</th>

  <th width="20%">Owner</th>

  <th width="20%">NextRunTime </th>

  <th width="20%">CreationTime </th>

  <th width="20%">StartTime </th>

  <th width="20%">EndTime </th>

  <th width="20%">Recurrence </th>

  <th width="20%">Duration</th>

  <th width="20%">Server</th>

  <th width="20%">Destination</th>

  <th width="20%">Frequency</th>

</tr>

<%

//<th width="30%">Folder Path </th>

  

        String user = request.getParameter("username");

  String password = request.getParameter("password");        

  String cmsName = request.getParameter("cmsname");        

  String cmsAuthType = request.getParameter("authType");

  String paramStartTime = request.getParameter("start");  

  String paramEndTime = request.getParameter("end");  

  String reportInstanceStartTime=null;

  String reportInstanceEndTime=null;

  String reportCreationTime=null;

  String statusCheck=null;

  String typeCheck=null;

  String reportOwner=null;

  String reportNextRuntime=null;

  String finalFolderPath=null;

  String recurringProp=null;

  long diffSeconds=0;

  String serverProp=null;

  java.util.Date startTime=null;

        java.util.Date endTime=null;

  java.util.Date creationTime=null;

  java.util.Date nextRunTime=null;

       

        String DATE_FORMAT="dd/MM/yyyy HH:mm:ss";

  IEnterpriseSession es=null;

  

  int index = 1;

   

      

  try

  {

  es = CrystalEnterprise.getSessionMgr().logon( user, password, cmsName, cmsAuthType);                

  IInfoStore iStore = (IInfoStore) es.getService("", "InfoStore");

  //IInfoObjects infoobjects = iStore .query("select si_name,si_nameduser,si_userfullname from ci_systemobjects where si_kind='user'"); 

  //IInfoObjects infoobjects = iStore .query("select top 10000 * from ci_infoobjects where si_instance=1 and si_starttime>='2014.12.01.00.00.00' and si_starttime<='2014.12.31.00.00.00' order by si_starttime desc");

  StringBuilder sqlQuery = new StringBuilder();

  sqlQuery.append("select * from ci_infoobjects where si_instance=1 and si_starttime>='")

  .append(paramStartTime)

  .append("' and si_starttime<='")

  .append(paramEndTime)

  .append("' order by si_starttime");

  IInfoObjects infoobjects = iStore.query(sqlQuery.toString());

  //IInfoObjects infoobjects = iStore .query("select * from ci_infoobjects where si_instance=1 and si_starttime>='2015.04.18.00.00.00' and si_starttime<='2015.04.19.20.00.00' order by si_starttime");

  //IInfoObjects infoobjects = iStore .query("select top 20000 * from ci_infoobjects where si_instance=1 and si_parentid='5474529' ");

  SimpleDateFormat sdf= new SimpleDateFormat(DATE_FORMAT);

  for(int i=0;i<infoobjects.size();i++)

  {

  int count=i+1;

  IInfoObject infoobject=(IInfoObject) infoobjects.get(i);

  IProperties reportProperties=(IProperties)infoobject.properties();

  ISchedulingInfo schedInfo=infoobject.getSchedulingInfo();

  IProperties schedProperties=schedInfo.properties();

  int reportID=infoobject.getID();

  String reportName=infoobject.getTitle();

  String reportKind=infoobject.getKind();

  out.println("<tr><td>"+reportID+"</td>");

  out.println("<td>"+reportName+"</td>");

  out.println("<td>"+reportKind+"</td>");

  int status=schedInfo.getStatus();

  switch(status)

  {

  case ISchedulingInfo.ScheduleStatus.COMPLETE: //Job is completed

  statusCheck="COMPLETE";

  out.println("<td>"+statusCheck+"</td>");

  break;

  case ISchedulingInfo.ScheduleStatus.FAILURE: //Job has failed.

  statusCheck="FAILURE";

  out.println("<td>"+statusCheck+"</td>");

  break;

    

  case ISchedulingInfo.ScheduleStatus.PAUSED: //Job is paused.

  statusCheck="PAUSED";

  out.println("<td>"+statusCheck+"</td>");

  break;

    

  case ISchedulingInfo.ScheduleStatus.PENDING: //Job is pending.

  statusCheck="PENDING";

  out.println("<td>"+statusCheck+"</td>");

  break;

    

  case ISchedulingInfo.ScheduleStatus.RUNNING: //Job is running.

  statusCheck="RUNNING";

  out.println("<td>"+statusCheck+"</td>");

  break;

  }

  int id=infoobject.getParentID();

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

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

  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("<td>"+finalFolderPath+"</td>");

 

  }

 

  IProperty reportProperty=reportProperties.getProperty("SI_OWNER");

  reportOwner=reportProperty.getValue().toString();

  out.println("<td>"+reportOwner+"</td>");

       

  if(reportProperties.getProperty("SI_NEXTRUNTIME")  != null)

  {

  nextRunTime=reportProperties.getDate("SI_NEXTRUNTIME");

  reportNextRuntime=sdf.format(nextRunTime);

  out.println("<td>"+reportNextRuntime+"</td>");

  }

  else

  {

  reportNextRuntime="Property Doesnot exists";

  out.println("<td>"+reportNextRuntime+"</td>");

  }

  if(reportProperties.getProperty("SI_CREATION_TIME") != null)

  {

  creationTime = reportProperties.getDate("SI_CREATION_TIME");

  reportCreationTime=sdf.format(creationTime);

  out.println("<td>"+reportCreationTime+"</td>");

  }

  else

  {

  reportCreationTime="Property Doesnot exists";

  out.println("<td>"+reportCreationTime+"</td>");

  }

  if(reportProperties.getProperty("SI_STARTTIME") != null)

                {

  startTime=reportProperties.getDate("SI_STARTTIME");

  reportInstanceStartTime=sdf.format(startTime);

  out.println("<td>"+reportInstanceStartTime+"</td>");

  startTime=sdf.parse(reportInstanceStartTime);

  }

  else

  {

  reportInstanceStartTime="Property Doesnot exists";

  out.println("<td>"+reportInstanceStartTime+"</td>");

  }

  if(reportProperties.getProperty("SI_ENDTIME") != null)

                {

  endTime=reportProperties.getDate("SI_ENDTIME");

  reportInstanceEndTime=sdf.format(endTime);

  out.println("<td>"+reportInstanceEndTime+"</td>");

  endTime=sdf.parse(reportInstanceEndTime);

  }

  else

  {

  reportInstanceEndTime="Property Doesnot exists";

  out.println("<td>"+reportInstanceEndTime+"</td>");

  }

  IProperty recurringProperty=reportProperties.getProperty("SI_RECURRING");

  recurringProp=recurringProperty.getValue().toString();

  out.println("<td>"+recurringProp+"</td>");

  if(recurringProp.equals("false"))

  {

  long diff=endTime.getTime() - startTime.getTime();

  diffSeconds=diff/1000;

  out.println("<td>"+diffSeconds+"</td>");

  }

  else

  {

  out.println("<td>Not Applicable</td>");

  }

  IProperty serverProperty=schedProperties.getProperty("SI_MACHINE_USED");

  if(serverProperty!=null)

  {

  serverProp=serverProperty.getValue().toString();

  //out.println("<td>"+serverProp+"</td></tr>");

  out.println("<td>"+serverProp+"</td>");

  }

  else

  {

  serverProp="Server Not assigned";

  out.println("<td>"+serverProp+"</td>");

  }

  IProperty destProperty=schedProperties.getProperty("SI_DESTINATIONS");

  out.println("<td>"+destProperty+"</td>");

  int type=schedInfo.getType();

  //out.println(type);

  if (type!=0){

  switch(type)   

  {  

  case CeScheduleType.ONCE:    

  typeCheck="ONCE";  

  out.println("<td>"+typeCheck+"</td>");     

  break;

  

  case CeScheduleType.HOURLY:

  typeCheck="HOURLY"; 

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.DAILY:   

  typeCheck="DAILY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.WEEKLY:

  typeCheck="WEEKLY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;       

  case CeScheduleType.MONTHLY:   

  typeCheck="MONTHLY";    

  out.println("<td>"+typeCheck+"</td>"); 

  break;        

  case CeScheduleType.NTH_DAY: 

  typeCheck="NTH_DAY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;           

  case CeScheduleType.FIRST_MONDAY:  

  typeCheck="FIRST_MONDAY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.LAST_DAY:   

  typeCheck="LAST_DAY";    

  out.println("<td>"+typeCheck+"</td>");   

  break;        

  case CeScheduleType.CALENDAR: 

  typeCheck="CALENDAR"; 

  out.println("<td>"+typeCheck+"</td>");    

  break;           

  case CeScheduleType.CALENDAR_TEMPLATE:

  typeCheck="CALENDAR_TEMPLATE";  

  out.println("<td>"+typeCheck+"</td>");    

  break;

  }

  }

  else {

  out.println("<td>Now</td>");

  }

                    index++;

  }

  }

      catch(SDKException e)

  {

  out.println(e.getMessage());

  }

  finally

  {

  es.logoff();

  }

%>

Code 2

-----------------------

<%

%>

<HTML>

  <HEAD>

    <TITLE></TITLE>

  </HEAD>

  <BODY>

  <table>

    <form action="InstanceDetails.jsp" method="post">

        <tr><td>CMS Name: </td><td><input name="cmsname" ></td></tr>

        <tr><td>User Name: </td><td><input name="username" ></td></tr>

        <tr><td>Password: </td><td><input type="password" name="password"></td></tr>

        <tr><td>Start</td><td><input name="start"></td></tr>

        <tr><td>End: </td><td><input name="end"></td></tr>

        <tr>

        <tr><td>Authentication Type:</td><td>

  <select name="authType" size=1 width="250">

                <option value='secEnterprise' selected>Enterprise</option>

                <option value='secLDAP'>LDAP</option>

            </select>

            </td></tr>

            <tr></tr>

        <tr><td>

      <P> </P><td></td></tr>

       <tr><td><INPUT type=submit value=submit></form></td></tr>

     

</table>

</BODY></HTML>

Please advise

Accepted Solutions (1)

Accepted Solutions (1)

former_member204024
Participant
0 Kudos

Hi,

I have attached the modified code.  My changes are at line number 180 & 116 in the attached txt file.  I haven't scheduled it before, so I couldn't clarify your 3rd question.

Please let me know how it goes.

Regards,

Subramanian S.

Former Member
0 Kudos

Hi Subramanian,

Thank you very much for the prompt response, I'll run the code and see how it works now!

Former Member
0 Kudos

Hi Subramanian,

The first thing is there is <t at the top of the page.

Secondly, is it possible to see the error messages in a separate column by adding an extra column  <th> and grab data from <td>, this way we can do some BI on BI system .

I am trying to improve this code step by step from SDK experts (like you), and develop a jar file which can be run eventually from CMC as a program object. The majority of the code is given by Prithviraj Shekawat and I did some minor modifications

Thanks again for the prompt response

former_member204024
Participant
0 Kudos

Hi Peter,

I couldn't get you properly. So you need a separate column for error messages.  Please correct me if I am wrong.

Regards,

Subramanian S.

former_member204024
Participant
0 Kudos

Hi,

Please find the updated code.

Regards,

Subramanian S.

Former Member
0 Kudos

Thanks, this works, but for some reason the very last row looks like this, no other column values are displayed and there is <td next to Type.

IdTitleTypeStatusError MessageFolderOwnerNextRunTimeCreationTimeStartTimeEndTimeRecurrenceDurationServerDestinationFrequency
9275808ABC ReportWebi</td
Former Member
0 Kudos

Hi Subramanian,

Never mind I found the first code is appended with second code from the attachment and hence getting the issue. I removed the code and it worked perfectly.

We will see if some one can give their input in regards to my quest #3.

Thanks a lot again!

former_member204024
Participant
0 Kudos

Meanwhile I will also search SCN and google to get any inputs.

Regards,

Subramanian S.

Former Member
0 Kudos

The actual idea came from from BI Platform Support tool page.

How to run the BISupportTool as a Program Object - Business Intelligence (BusinessObjects) - SCN Wik...

Hope this may help.

former_member204024
Participant
0 Kudos

Hi Peter,

From the link that you shared what I came to know is we can schedule a jar file.

Now you want the output of the JSP in your local disk.  Am I right?

To achieve this we have to convert this into a java class and pack it in a jar file.  We have to create the output html file from this java class.

If we schedule this jar file then we will get the output html files at regular intervals.

I don't think directly this JSP file can be scheduled.

Regards,

Subramanian S.

Former Member
0 Kudos

HI Subramanian,

The output file can be saved to local disk or a network shared drive.

Instead HTML, I'll be adding some extra code to convert it to an Excel file.

Yes, a jsp file can not be scheduled, whereas using CMC we can schedule a jar file, not sure how to package and test end to end.

Former Member
0 Kudos

Hi Subramanian,

I noticed another thing, that the output to browser is getting truncated after 2000 records, I am expecting ~3000 rows of data for a week.

Could this be the application issue (CMS) not able to send all the data or anything we can do from the code/settings? Please advise.

Former Member
0 Kudos

Hi Peter,

You would need to convert the code to a java program object, which would be a standalone java class implementing IProgramBase interface. The coding logic remains same just that you would need to change few of the coding syntax to standalone java files. The java class then needs to be compiled and a jar file has to be created and published to enterprise as a java program object.

You can refer to the below post to check on the logic for java program objects.

http://scn.sap.com/community/bi-platform/java-sdk/blog/2014/08/27/server-status-using-java-program-o...

Thanks,

Prithvi

former_member204024
Participant
0 Kudos

Hi

From the code that you shared you will get only 1000 records. Since its the default limit.

Please refer to Java Batch Processing of an Infostore Object on an Enterprise System - Business Intelligence (Busine... for batch processing.

You can also look into the documentation of IInfoobject.getResultSize() method.

Regards,

Subramanian S.

Former Member
0 Kudos

Thanks Prithvi, nice article. I'll let you know how it works.

Former Member
0 Kudos

Thanks Subramanian,

This is helpful, need to try it and let you know.

Answers (0)