BO4 SDK 检索所有使用了某个universe object的报表

news/2024/11/23 5:54:34/

这仅仅是保证了再报表的query里拉出了这个对象不能保证在报表层面也使用了这个对象,,检索的对象名称为“Domestic / International”,在BO4中SDK中已经不提供XI3中的Query对象所以采用另一种办法来做:

参考文档http://bukhantsov.org/2012/11/java-code-to-list-the-objects-used-in-a-webi-4-0-document/


主要用到了webi_client_toolkit.jar 这个包,这个包并不在SAP官网文档中提到,也不再客户端安装目录下,必须要服务器端安装目录下取得C:\Program Files (x86)\SAP BusinessObjects\Tomcat6\webapps\BOE\WEB-INF\eclipse\plugins\webpath.AnalyticalReporting\web\WEB-INF\lib\webi_client_toolkit.jar



<%@page import="java.io.FileOutputStream"%><%@ page language="java" errorPage="err_page.jsp"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.List" %>
<%@ page import="java.io.*" %>
<%@ page import="jxl.Workbook" %>
<%@ page import="jxl.write.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.lang.Iterable" %>
<%@ page import="com.businessobjects.adv_ivcdzview.Utils"%>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IEvents" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.plugin.desktop.event.IEvent" %>
<%@ page import="com.crystaldecisions.sdk.properties.IProperties" %>
<%@ page import="com.businessobjects.sdk.plugin.desktop.webi.IWebi" %>
<%@ page import="com.crystaldecisions.sdk.plugin.desktop.report.IReport" %>
<%@ page import="com.businessobjects.rebean.wi.*" %>
<%@ page import="com.sap.webi.client.toolkit.reporting.ReportDictionaryHelper"%>
<%@ page import="com.businessobjects.sdk.core.Core"%>
<%@ page import="com.businessobjects.sdk.core.context.IContext"%>
<%@ page import="com.sap.sl.dictionary.DictionaryExpression"%>
<%@ page import="com.sap.sl.dictionary.Variable"%>
<%@ page import="com.sap.webi.client.toolkit.Deployment"%>
<%@ page import="com.sap.webi.client.toolkit.LoginKey"%>
<%@ page import="com.sap.webi.client.toolkit.SessionContext"%>
<%@ page import="com.businessobjects.rebean.wi.model.engine.IDocumentInstance"%>
<%@ page import="com.businessobjects.rebean.wi.services.IDocumentInstanceManagementService"%>
<%@ page import="java.util.Locale"%>

<%
 
    IEnterpriseSession enterpriseSession=null ;
    OutputStream os=null;
    WritableWorkbook workbook=null;
        try
     {     
//   IEnterpriseSession enterpriseSession = LoginAndGetSession.getSession();
     //String S_USER=request.getParameter("user").trim();
     //String S_PASS=request.getParameter("pwd").trim();
     //String startDate=request.getParameter("startDate").trim();
     //String endDate=request.getParameter("endDate").trim();
     //String S_HOST="@PPECLUSTER";
     //String S_SECURITY="secEnterpris";
     
     //System.out.println(S_USER);
     //System.out.println(S_PASS);
     //System.out.println(startDate);
     //System.out.println(endDate);
     //System.out.println(S_HOST);
     //System.out.println(S_SECURITY);
     ISessionMgr iSessionMgr = CrystalEnterprise.getSessionMgr();     
     System.out.println("start to log in");
     enterpriseSession=iSessionMgr.logon("adtuser", "***", "*****", "secEnterprise");
    // DocumentInstance doc;
     ReportEngine objReportEngine=null;
     try{
            objReportEngine = (ReportEngine)enterpriseSession.getService("","WebiReportEngine"); ;
            }catch(Exception e){                
            objReportEngine = (ReportEngine)enterpriseSession.getService("ReportEngine"); ;
            }
        
     System.out.println("start to log in2");
     {
         //test
        
     }
       IInfoStore infostore=(IInfoStore)enterpriseSession.getService("InfoStore");//2012.12.01.00.00.00
         //get total of instance
       IInfoObjects allReportcounts= infostore.query("SELECT  count( SI_ID) FROM CI_INFOOBJECTS WHERE SI_KIND in('WEBI')AND SI_INSTANCE=0 and SI_CREATION_TIME<='2011.01.01.00.00.00'" );
       IInfoObject allRportcount=(IInfoObject)allReportcounts.get(0);
       //System.out.print("The total of instance is: "+allReports.size());
       IProperties counts=(IProperties)allRportcount.properties().getProperties("SI_AGGREGATE_COUNT");
       int IDCount=counts.getInt("SI_ID");
       System.out.print("The total of instance is: "+IDCount);
       int k=IDCount;   
       IInfoObjects allReports= infostore.query("SELECT  top "+k+" * FROM CI_INFOOBJECTS WHERE SI_KIND in('Webi') and SI_INSTANCE=0 and SI_CREATION_TIME<='2011.01.01.00.00.00'" );
       String targetfile = "D:\\reportwithLOB8.xls";
       File f=new File(targetfile);
       if(f.exists())f.delete();
       os=new FileOutputStream(targetfile);       
       workbook = Workbook.createWorkbook(os);   
       WritableSheet sheet = workbook.createSheet("Hongrao",0);
       int row=0;
       
           String serializedSession = enterpriseSession.getSerializedSession();
           SessionContext sessionContext = com.businessobjects.adv_ivcdzview.Utils.getSessionContextManager().matchSessionContext(Deployment.DHTML, serializedSession, true);
           Locale localLocale = Locale.getDefault();
           sessionContext.getLoginInfo().set(LoginKey.LOCALE, localLocale);
           sessionContext.logonWithSerializedSession();
           IContext context = sessionContext.getCoreContext();
           IDocumentInstanceManagementService documentInstanceManagementService = Core.getService(IDocumentInstanceManagementService.class);
             
       
       egencia:            
         for (int i=0;i<k;i++)
         {  
             try{
           IWebi a=(IWebi)allReports.get(i);
           //doc= objReportEngine.openDocument(a.getID());
           // a.getso
           {}
          
         String path="";
         String docName="";
         String createdate="as";
         String lastdate="as";
         SimpleDateFormat sdf  =   new  SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " );
         {
           IInfoObject reportFolder = a.getParent();
           docName=a.getTitle();
           createdate=sdf.format( a.properties().getDate("SI_CREATION_TIME"));
           lastdate=sdf.format( a.properties().getDate("SI_UPDATE_TS"));
           
       //   System.out.print(a.getTitle()+"\n");
           if (a.getParentID() == 0)
                       path="Public Folders";
                 else
                 { try{
                       while (1 > 0)
                       {
                             path = reportFolder.getTitle() + "/" + path;
                           //  System.out.print(" Report path "+reportFolder.getTitle());
                             if (reportFolder.getParentID() == 0)
                             {path = "Public Folders"+ "/" + path;
                             // System.out.print(path+"\n");
                              
                                   break;
                             }
                             else
                             {
                                   reportFolder = reportFolder.getParent();
                                   //System.out.print(reportFolder);
                             }
                       }
                 }catch(Exception es){}
                 }
          
           
         }
         
         if(path.toLowerCase().indexOf("egencia")<0) continue;
         {

             IDocumentInstance doc =documentInstanceManagementService.openDocument(context, a.getID());
             List <DictionaryExpression>list = ReportDictionaryHelper.getDictionaryObjectsFlatList(context, doc);
           
             int have=0;
             if (list.size() > 0) {
               System.out.println(a.getTitle()+" OBJECTS:"+i+":"+list.size());
              // for(int g=0;g<list.size();g++){
                   //System.out.println(expr.getName());
                  // list.
               //}
             
               for (DictionaryExpression expr:list) {
                 
                 if(expr.getName().indexOf("nternatio")>1 && expr.getName().indexOf("mestic")>1)
                 { have=1;
                 System.out.println(expr.getName());
                 
                 break;
                 }
               }
               
             }
             documentInstanceManagementService.closeDocument(context, doc);
            if(have==0) continue egencia;
            
             
         }
         Label labelcon1=new Label(0,row,path);
         Label labelcon2=new Label(1,row,docName);
         Label labelcon3=new Label(2,row,createdate);
         Label labelcon4=new Label(3,row,lastdate);
         sheet.addCell(labelcon1);
         sheet.addCell(labelcon2);
         sheet.addCell(labelcon3);
         sheet.addCell(labelcon4);
         row+=1;
             }catch(Exception eh){}
         }
         workbook.write();
         workbook.close();
         os.close();
         out.print("sucess!");
        
     }
        catch(SDKException sdk){
            workbook.close();
            os.close();
            out.print(sdk.getMessage());}
        finally{
            enterpriseSession.logoff();
        }
%>


http://www.ppmy.cn/news/804730.html

相关文章

z-blog+php+漏洞,bo-blog index.php include任意php文件漏洞

来源:[F.S.T]火狐技术联盟 文章作者:我非我[F.S.T] 漏洞发现日期:2005.6.13 漏洞涉及版本:Bo-Blog Version < 1.7.0108(未打补丁前) 漏洞分析及利用: 刚发现bo-blog的一个致命的漏洞。我是看1.7.0095版本的。不过估计最新的也有这个漏洞.在index.php中的job变量没有过滤.导致…

Java中 VO、 PO、DO、DTO、 BO、 QO、DAO、POJO之dozer mapper使用

PO(persistant object) 持久对象 在 o/r 映射的时候出现的概念&#xff0c;如果没有 o/r 映射&#xff0c;没有这个概念存在了。通常对应数据模型 ( 数据库 ), 本身还有部分业务逻辑的处理。可以看成是与数据库中的表相映射的 java 对象。最简单的 PO 就是对应数据库中某个表中…

BO系列产品介绍

看SAP提供的BO产品目录&#xff0c;比较晕&#xff0c;有很多产品。不同产品的定位及作用不能一一去看吧&#xff0c;而且也没办法对BO产品进行总体的了解&#xff0c;然后再有针对性的进行个别产品的深入了解。但是对BO系列的产品总体介绍的文档比较少。SAP BO产品按企业规模推…

po ov pojo DAO,BO各种差异用法设计

要在页面上查看一些固定的信息&#xff0c;用到了VO类和 从内存中加载数据。来说下各 O 的差异下面说一下 VO类。 首先&#xff0c;java有几种对象(PO,VO,DAO,BO,POJO) 一、PO:persistant object 持久对象,可以看成是与数据库中的表相映射的java对象。使用Hibernate来生成PO…

vue bpmn.js中bo.get is not a function问题处理-bpmn右侧属性问题

vue bpmn.js中bo.get is not a function问题处理-bpmn右侧属性问题 当我们使用 bpmn.js 中的右侧属性版时&#xff0c;需要引入 bpmn-js-properties-panel 这个插件&#xff0c;同时引入 camunda-bpmn-moddle 按照官网或者其他人的教程&#xff0c;装到最后出现&#xff1a;bo.…

关于BO SDK

1 官网BO SDK http://scn.sap.com/docs/DOC-27465 2 最简单的BO SDK DEMO -- Getting Started with BO JAVA SDK http://ginoscheppers.wordpress.com/2011/02/10/quick-start-using-eclipse-and-bo-xi-java-sdk/ http://blog.sina.com.cn/s/blog_7b87efa50101c4ry.ht…

Java PO BO DTO VO bean对象互相转换高性能实现工具

目录 方案一&#xff1a;Cglib BeanCopier方案二&#xff1a;Spring BeanUtils方案三&#xff1a;MapStruct方案四&#xff1a;Orika方案五&#xff1a;Dozer 方案一&#xff1a;Cglib BeanCopier import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j;…

dearmwear和PHP和HtmL_BO-BLOG模板制作指南(上)

一、Bo-blog程序简介 Bo-Blog日志程序(以下简称程序)是由Bob Shen开发的管理员和副管理员共同写作的blog程序&#xff0c;基于PHP脚本和文本数据库。 Bo-blog官方网站&#xff1a;http://www.bo-blog.com Bo-blog官方论坛:http://www.bmforum.com/bmb/forums.php?forumid81 二…