In this blog, I will be demonstrating a program object to export the list of reports organized in folders in a Business Objects environment.
Prerequisites:
Creation of a Java Program Object:
import com.crystaldecisions.sdk.plugin.desktop.program.*;
import com.crystaldecisions.sdk.framework.*;
import com.crystaldecisions.sdk.occa.infostore.*;
import com.crystaldecisions.sdk.exception.*;
import java.io.FileWriter;
import java.io.*;
import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;
import com.crystaldecisions.sdk.properties.IProperties;
import com.crystaldecisions.sdk.properties.IProperty;
import com.crystaldecisions.sdk.plugin.desktop.folder.*;
import java.util.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFPrintSetup;
public class ListReportsInFolder implements IProgramBase
{
public void run(IEnterpriseSession enterprisesession,IInfoStore iStore,String str[]) throws SDKException
{
System.out.println("Connected to " + enterprisesession.getCMSName() + "CMS");
System.out.println("Using the credentials of " + enterprisesession.getUserInfo().getUserName() );
String reportOwner=null;
String reportCreationTime=null;
String finalFolderPath=null;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("new sheet");
XSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("Report Name");
rowhead.createCell((short) 1).setCellValue("Report ID");
rowhead.createCell((short) 2).setCellValue("FolderPath");
rowhead.createCell((short) 3).setCellValue("Owner");
rowhead.createCell((short) 4).setCellValue("Creation Time");
int index = 1;
try
{
iStore = (IInfoStore) enterprisesession.getService("", "InfoStore");
if(str.length>0)
{
System.out.println("The runtime parameters for this app were:");
BufferedReader br=new BufferedReader(new FileReader(str[0]));
String parentId;
while((parentId=br.readLine()) != null)
{
IInfoObjects infoobjects = iStore .query("SELECT * from CI_INFOOBJECTS WHERE si_instance=0 and si_kind in('crystalreport','webi') and si_parentid="+parentId+ " order by si_creation_time");
for(int i=0;i<infoobjects.size();i++)
{
IInfoObject infoobject=(IInfoObject) infoobjects.get(i);
ISchedulingInfo schedInfo=infoobject.getSchedulingInfo();
int reportID=infoobject.getID();
String reportName=infoobject.getTitle();
System.out.println("Report Id: "+reportID);
System.out.println("Report Name: "+reportName);
IProperties reportProperties=(IProperties)infoobject.properties();
IProperty reportProperty=reportProperties.getProperty("SI_OWNER");
if(reportProperty != null)
{
reportOwner=reportProperty.getValue().toString();
System.out.println("Report Owner: "+reportOwner);
}
IProperty reportProperty1=reportProperties.getProperty("SI_CREATION_TIME");
if(reportProperty1 != null)
{
reportCreationTime=reportProperty1.getValue().toString();
System.out.println("Report Creation Time: "+reportCreationTime);
}
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.getID();
if(infoobject1.getKind().equals("Folder"))
{
finalFolderPath="/";
IFolder iifolder=(IFolder)infoobject1;
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();
}
System.out.println("Report Folder Path: "+finalFolderPath);
}
XSSFRow row = sheet.createRow((short)index);
row.createCell((short) 0).setCellValue(reportName);
row.createCell((short) 1).setCellValue(reportID);
row.createCell((short) 2).setCellValue(finalFolderPath);
row.createCell((short) 3).setCellValue(reportOwner);
row.createCell((short) 4).setCellValue(reportCreationTime);
index++;
}
}
br.close();
Date date=new Date();
String date1= date.toString();
String date2=date1.replaceAll("\\W", "_");
FileOutputStream fileOut = new FileOutputStream(str[1] +"_"+date2 +".xlsx" );
wb.write(fileOut);
fileOut.close();
System.out.println("Excel File Generated at "+str[1]);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
http://help.sap.com/businessobject/product_guides/boexir4/en/xi4_boejava_dg_en.zip
http://help.sap.com/businessobject/product_guides/boexir31/en/boesdk_java_dg_12_en.zip
Publishing the Java Program Object to the Enterprise System:
You would then have an excel file generated at the above specified location with the details of reports in a Business Objects environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |