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

2020-09-15 11:43发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 我使用的是BO 4....

         点击此处--->   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条回答
四川大学会员
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()));
 }
 }


 

一周热门 更多>