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

I have been working on few requirements to have a schedulable object in the enterprise system to have details about the objects from the CMS repository using the BusinessObjects Enterprise Java SDKs.

For this have used the BusinessObjects scheduler apart from having a third party scheduler by creating a Java Program Objects.

In this blog, I will be presenting one such example of getting the BusinessObjects Server Status by creating a java program object.

Prerequisites:

  1. BusinessObjects Enterprise System
  2. BusinessObjects Enterprise Java SDKs

Creation of a Java Program Object:

  • For creating a java program object, you need to write a java class which has to implement the interface IProgramBase.
  • Once you create the java file, you would then need to create a jar file for the java class by setting all the required jars in your classpath.
  • Below is a sample java file to retrieve the server status of BusinessObjects servers and export the results to an excel file.
Server Status Export to Excel

import com.businessobjects.sdk.plugin.desktop.common.*;
import com.businessobjects.sdk.plugin.desktop.enterprisenode.*;
import com.businessobjects.sdk.plugin.desktop.service.*;
import com.businessobjects.sdk.plugin.desktop.servicecontainer.*;
import com.crystaldecisions.sdk.framework.*;
import com.crystaldecisions.sdk.occa.infostore.*;
import com.crystaldecisions.sdk.plugin.desktop.server.*;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.plugin.desktop.program.*;
import java.util.*;
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;

public class ServerServices implements IProgramBase
{
public void run(IEnterpriseSession enterprisesession,IInfoStore infoStore,String str[]) throws SDKException
{


    System.out.println("Connected to " + enterprisesession.getCMSName() + "CMS");
    System.out.println("Using the credentials of " + enterprisesession.getUserInfo().getUserName() );
 
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("new sheet");
        HSSFRow rowhead = sheet.createRow((short)0);
        rowhead.createCell((short) 0).setCellValue("Server Name");
        rowhead.createCell((short) 1).setCellValue("Server ID");
        rowhead.createCell((short) 2).setCellValue("Server CUID");
        rowhead.createCell((short) 3).setCellValue("Server Description");
        rowhead.createCell((short) 4).setCellValue("Server State");
        rowhead.createCell((short) 5).setCellValue("Server Is Alive");
        rowhead.createCell((short) 6).setCellValue("Server Is Disabled");
     
    try
    {
     
        infoStore = (IInfoStore) enterprisesession.getService("", "InfoStore"); 
        int index = 1;
     
        if(str.length>0)
    {
        System.out.println("The runtime parameters for this app were:");
     
        for(int k=0;k<str.length;k++)
        {
            if(str[k] != null)
            {
            System.out.println(str[k]);
 
 
    final String SERVERS_QUERY = "Select "
                              + "    SI_ID, SI_CUID, SI_PID, SI_SERVER_ID, SI_NAME, "
                              + "    SI_SERVER_DESCRIPTOR, SI_DISABLED, SI_SERVER_IS_ALIVE, "
                              + "    SI_STATUSINFO, SI_SIA_HOSTNAME, SI_ENTERPRISENODE, "
                              + "    SI_CONFIGURED_CONTAINERS, SI_HOSTED_SERVICES, "
                              + "    SI_ML_DISPLAY_NAME "
                              + " From "
                              + "    CI_SYSTEMOBJECTS "
                              + " Where "
                              + "    SI_KIND='Server'";
                           
                           
    IInfoObjects serverInfoObjects = infoStore.query(SERVERS_QUERY);

 

        for(Iterator iserver = serverInfoObjects.iterator() ; iserver.hasNext() ; )
        {
            IServer    server;
            String      serverName;
            int        serverID;
            String      serverCUID;
            int        serverPID;
            String      serverServerID;
            int        serverEnterpriseNodeID;
            String      serverSIAHostname;
            String      serverDescriptor;
            String      serverState;
            boolean    serverIsAlive;
            boolean    serverIsDisabled;

     

            /*
            * Retrieve selected server properties.
            */

            server                = (IServer) iserver.next();
            serverName            = server.getTitle();
            serverID              = server.getID();
            serverCUID            = server.getCUID();
            serverPID              = server.getPID();
            serverServerID        = server.getServerID();
            serverEnterpriseNodeID = server.getEnterpriseNodeID();
            serverSIAHostname      = server.getSIAHostname();
            serverDescriptor      = server.getServerDescriptor();
            serverState            = server.getState().toString();
            serverIsAlive          = server.isAlive();
            serverIsDisabled      = server.isDisabled();
         
         
            HSSFRow row = sheet.createRow((short)index);

                    row.createCell((short) 0).setCellValue(serverName);
                    row.createCell((short) 1).setCellValue(serverID);
                    row.createCell((short) 2).setCellValue(serverCUID);
                    row.createCell((short) 3).setCellValue(serverDescriptor);

                    row.createCell((short) 4).setCellValue(serverState);
                    row.createCell((short) 5).setCellValue(serverIsAlive);
                    row.createCell((short) 6).setCellValue(serverIsDisabled);
                 
                    index++;
        }
     
        FileOutputStream fileOut = new FileOutputStream(str[0]);
        wb.write(fileOut);
        fileOut.close();
        fileOut.flush();

        System.out.println(" Excel file created successfully"); 
    }
 
    }
    }
    }
    catch(Exception e)
    {
    System.out.println(e.getMessage());
    }


}
}

  • Copy the above code into a text file and save it as ServerServices.java. Please make sure that your java class name and file name should exactly be the same(case sensitive).
  • Compile the above java class by having all the jars required to run the file in the classpath. You can also use ecllipse IDE to compile and create jar file. The list of jars can be found from the developers guide available at below links

    For BI 4.0

    http://help.sap.com/businessobject/product_guides/boexir4/en/xi4_boejava_dg_en.zip

    For XI 3.1

    http://help.sap.com/businessobject/product_guides/boexir31/en/boesdk_java_dg_12_en.zip

  • Refer to the section 'JAR files needed for deployment of Business Objects Software' from the above guides to get the list of jar files.
  • You would specifically need the jar files listed under 'BusinessObjects Enterprise Java SDK'
  • Once you have compiled the code, create a jar file for your compiled .class file.

Publishing the Java Program Object to the Enterprise System:

  1. In the CMC, go to Folders and create new folder "Objects" or navigate to an existing folder where you want to publish the program object
  2. Select the folder "Objects" and click on Manage | Add | Program File
  3. Choose as Program Type Java and add ServerServices.jar
  4. Right Click on ServerStatus within your Objects folder and choose Properties | Default Settings | Program Parameters
  5. Specify as "Class to run:" ServerServices.
  6. In the Arguments pass the the location along with excel file name where you want the excel file to be generated(eg. c:/serverstatus.xls).
  7. Test "Run Now" and schedule the Program Object.

You would then have an excel file generated at the above specified location which contains the server status details.

Labels in this area