为什么无法将IInfoStore对象转换为IDestinationPlugin?

2020-09-15 11:43发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,

我使用的是BO 4.0,并且想使用.copyToPlugin(),但是Cast无法正常工作。

我的代码是:

第1行)IDestinationPlugin destPlugin =(IDestinationPlugin)boInfoStore.query("从ci_parentId = 29和si_name ='CrystalEnterprise.SMTP'"的ci_systemobjects中选择*); 第2行)boDestination.copyToPlugin(destPlugin);


发生以下异常:

com.crystaldecisions.sdk.occa.infostore.internal.InfoObject无法转换为com.crystaldecisions.sdk.occa.infostore.IDestinationPlugin

是否可以修复它?

先谢谢您

拉法

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,

我使用的是BO 4.0,并且想使用.copyToPlugin(),但是Cast无法正常工作。

我的代码是:

第1行)IDestinationPlugin destPlugin =(IDestinationPlugin)boInfoStore.query("从ci_parentId = 29和si_name ='CrystalEnterprise.SMTP'"的ci_systemobjects中选择*); 第2行)boDestination.copyToPlugin(destPlugin);


发生以下异常:

com.crystaldecisions.sdk.occa.infostore.internal.InfoObject无法转换为com.crystaldecisions.sdk.occa.infostore.IDestinationPlugin

是否可以修复它?

先谢谢您

拉法

付费偷看设置
发送
7条回答
95年老男孩
1楼 · 2020-09-15 12:08.采纳回答

您的问题是InfoStore查询返回IInfoObject,而不是IInfoObject。 另外,您在where子句中不需要父ID。 将第一行代码更改为此:

IDestinationPlugin destPlugin =(IDestinationPlugin)boInfoStore.query("从ci_systemobjects中选择*,其中si_name ='CrystalEnterprise.SMTP'").get(0)

-Dell

四川大学会员
2楼-- · 2020-09-15 12:11

您要使用" CopyToPlugin"做什么?

这是我用于为新计划设置目标选项的代码。 这是从一个程序根据旧计划重新计划报告而来的。 它使用一些我编写的"帮助程序"对象来获取属性信息并针对InfoStore运行查询,但是您应该能够理解它。

 private void setEmailDest(IInfoObject newRpt,IInfoObject oldRpt,ScheduleInfo si)引发异常{
 尝试{
   IProperties destProps = PropertyHelper.getIProps(oldRpt.getSchedulingInfo()。properties()," SI_DESTINATIONS",_log);
   IProperties destSchedProps = destProps.getProperties(" 1")。getProperties(" SI_DEST_SCHEDULEOPTIONS");
  
   IDestinationPlugin newDestPlugin =(IDestinationPlugin)_qh.executeRawQuery(" SELECT TOP 1 *" +
            " FROM CI_SYSTEMOBJECTS WHERE SI_NAME ='CrystalEnterprise.Smtp'")。get(0);
   ISMTP newSmtp =(ISMTP)newDestPlugin;
   ISMTPOptions newOptions =(ISMTPOptions)newSmtp.getScheduleOptions();

   String [] destInfo = si.getDestinationInfoStr()。split(";");
   字符串msg ="";
   对于(String s:destInfo){
     如果(s.startsWith(" From:")){
       newOptions.setSenderAddress(s.replace(" From:","")));
     }否则,如果(s.startsWith(" Subject:")){
       newOptions.setSubject(s.replace(" Subject:",""));
     }否则if(!s.startsWith(" To:")&&!s.startsWith(" CC:")&&!s.startsWith(" BCC:")&&!s.startsWith(" Filename:")){
      //考虑到消息中可能存在分号;
       msg + = s;
     }
   }
   如果(!msg.isEmpty()){
     newOptions.setMessage(msg);
   }
  
   布尔bprop = PropertyHelper.getBooleanProp(destSchedProps," SI_SMTP_ENABLEATTACHMENTS",_log);
   newOptions.setAttachmentsEnabled(bprop);
   如果(bprop){
     IProperties文件= PropertyHelper.getIProps(destSchedProps," SI_OUTPUT_FILES",_log);
     如果(文件!=空){
       int cnt = PropertyHelper.getIntProp(files," SI_TOTAL",_log);
       for(Integer i = 1; i <= cnt; i ++){
         IProperties attach = PropertyHelper.getIProps(files,i.toString(),_log);
         newOptions.getAttachments()。add(PropertyHelper.getStringProp(attach," SI_MIME_TYPE",_log),
             PropertyHelper.getStringProp(attach," SI_EMBED_NAME",_log));
       }
     }
   }
  
   IProperties addr = PropertyHelper.getIProps(destSchedProps," SI_MAIL_ADDRESSES",_log);
   如果(addr!= null){
     int cnt = PropertyHelper.getIntProp(addr," SI_TOTAL",_log);
     for(整数i = 1; i <= cnt; i ++){
       newOptions.getToAddresses()。add(PropertyHelper.getStringProp(addr,i.toString(),_log));
     }
   }

   addr = PropertyHelper.getIProps(destSchedProps," SI_MAIL_CC",_log);
   如果(addr!= null){
     int cnt = PropertyHelper.getIntProp(addr," SI_TOTAL",_log);
     for(整数i = 1; i <= cnt; i ++){
       newOptions.getCCAddresses()。add(PropertyHelper.getStringProp(addr,i.toString(),_log));
     }
   }
    
   addr = PropertyHelper.getIProps(destSchedProps," SI_MAIL_BCC",_log);
   如果(addr!= null){
     int cnt = PropertyHelper.getIntProp(addr," SI_TOTAL",_log);
     for(整数i = 1; i <= cnt; i ++){
       newOptions.getBCCAddresses()。add(PropertyHelper.getStringProp(addr,i.toString(),_log));
     }
   }
       
   ISchedulingInfo schedInfo = newRpt.getSchedulingInfo();
    
   IDestination目标= schedInfo.getDestinations()。add(" CrystalEnterprise.Smtp");
   destination.setFromPlugin(newDestPlugin);
 } catch(SDKException e){
   抛出(新的Exception(" SDK例外设置电子邮件目标:" + e.getDetailMessage()));
 }
 }


 
CPLASF-自律
3楼-- · 2020-09-15 12:09

IInfoObjects插件= m_infoStore.query("从ci_systemobjects中选择*,其中si_parentId = 29和si_name ='CrystalEnterprise.SMTP'");

IDestinationPlugin插件=(IDestinationPlugin)plugins.get(0);

Tong__Ming
4楼-- · 2020-09-15 11:52

嗨,巴拉斯,

非常感谢您的帮助。

此致

Rafa

能不能别闹
5楼-- · 2020-09-15 11:54

此代码段可帮助您了解带有选项的目标插件。
https://help.sap.com/查看器/0225aa3e7b4b4b17b2d4a882e6f2de96/4.2.6/zh-CN/45a5375d6e041014910aba7db0e91070.html

 public void configurePublicationDestination(IEnterpriseSession enterpriseSession,String publicationName)抛出SDKException
 {
   IInfoStore infostore =(IInfoStore)enterpriseSession.getService(" InfoStore");

   字符串publicationQuery =" SELECT SI_ID,SI_PROCESSINFO,SI_SCHEDULEINFO"
     +"来自CI_INFOOBJECTS的SI_PUBLICATION_DOCUMENTS"
     +" WHERE SI_KIND ='" + IPublication.KIND
     +"'AND SI_NAME ='" + publicationName +"'AND SI_INSTANCE = 0";
   IInfoObjects出版物= infostore.query(publicationQuery);
   IPublication发布=(IPublication)publications.get(0);
        
   字符串pluginQuery =" SELECT *从CI_SYSTEMOBJECTS,其中SI_PARENTID = 29 AND"
     +" SI_NAME ='" + IManaged.PROGID +"'";
   IInfoObjects插件= infostore.query(pluginQuery);
   IDestinationPlugin inboxPlugin =(IDestinationPlugin)plugins.get(0);
        
   ISchedulingInfo scheduleInfo = publication.getSchedulingInfo();
   IDestinations目的地= scheduleInfo.getDestinations();

   IDestination inboxDestination = destinations.add(IManaged.PROGID);
   inboxDestination.setFromPlugin(inboxPlugin);
   inboxDestination.setDeliverPerUser(true);
        
   收集文档= publication.getSchedulableDocuments();
   迭代器documentIter = documents.iterator();
        
   while(documentIter.hasNext())
   {
     IInfoObject文档=(IInfoObject)documentIter.next();
     整数documentID =新的整数(document.getID());
            
     IDestinationFormat格式= inboxDestination.getDestinationFormats()。add();
     format.setSourceDocumentID(documentID);
     IFormatInfo formatInfo = format.getFormatInfos()。add();

     formatInfo.setSourceDocumentKind(document.getKind());
     formatInfo.setFormat(document.getKind(),IReportFormatOptions.CeReportFormat.PDF);
            
     IProcessingPublicationInfo processingPubInfo =(IProcessingPublicationInfo)publication.getDocumentProcessingInfoObject(documentID);
     IInfoObject reportDoc =(IInfoObject)processingPubInfo;
     formatInfo = processingPubInfo.getFormatInfos()。add();

     formatInfo.setSourceDocumentKind(document.getKind());
     formatInfo.setFormat(document.getKind(),IReportFormatOptions.CeReportFormat.PDF);
     publication.setDocumentProcessingInfo(documentID,document.getKind(),
     reportDoc.getProcessingInfo()。properties());
    }

    publication.save();
 } 
一只江湖小虾
6楼-- · 2020-09-15 11:53

啊! 您正在使用出版物...

是否可以访问电子邮件地址取决于出版物的配置方式。 对于出版物,地址可以由单独的报告提供,也可以通过使用BusinessObjects Profiles提供,因此它们不存储在对象的IScheduleInfo中。

-Dell

悻福寶寶
7楼-- · 2020-09-15 12:11

https://help.sap.com/viewer/0225aa3e7b4b4b17b2d4a882e6f2de96/4.2.6/zh-CN/45a65d446e041014910aba7db0e91070.html

将目标设置为SMTP

此示例指定将计划对象通过电子邮件发送到两个地址,这些地址通过名为servername.domain的SMTP服务器进行中继,该服务器正在端口25进行侦听

 void setDestinationToSMTP(IEnterpriseSession enterpriseSession,IInfoObject报告)抛出SDKException,IOException
 {
   IInfoStore infostore =(IInfoStore)enterpriseSession.getService(" InfoStore");
   ISchedulingInfo scheduleInfo = report.getSchedulingInfo();
    
   IInfoObjects smtpInfoObjects = infostore.query("从CI_SYSTEMOBJECTS选择SI_DEST_SCHEDULEOPTIONS,SI_PROGID,其中SI_NAME ='CrystalEnterprise.Smtp'");
   IInfoObject infoObject =(IInfoObject)smtpInfoObjects.get(0);
        
   IDestinationPlugin destinationPlugin =(IDestinationPlugin)infoObject;
   ISMTP smtp =(ISMTP)destinationPlugin;
       
   ISMTPOptions smtpOptions =(ISMTPOptions)smtp.getScheduleOptions();
   smtpOptions.setDomainName(" domain");
   smtpOptions.setServerName(" servername");
   smtpOptions.setPort(Integer.parseInt(" 25"));
   smtpOptions.setSMTPAuthenticationType(ISMTPOptions.CeSMTPAuthentication.LOGIN);
   smtpOptions.setSMTPUserName(" username");
   smtpOptions.setSMTPPassword(" password");
   smtpOptions.setSubject("电子邮件主题");
   smtpOptions.setMessage("这是电子邮件。");
        
   列出toAddresses = smtpOptions.getToAddresses();
   toAddresses.add(" user1@emaildomain.com");
   toAddresses.add(" user2@emaildomain.com");
        
   IDestination目标= scheduleInfo.getDestinations()。add(" CrystalEnterprise.Smtp");
   destination.setFromPlugin(destinationPlugin);
 }
 

一周热门 更多>