如何传递参数/提示&使用C#中的SAP BO 4.0 SDK安排webi报告

时间:2016-12-13 02:12:54

标签: c# asp.net sap

我可以使用C#安排网络报告。但是无法将提示/参数传递到报告中。请帮忙

 public string GetReport(int _reportId)
        {
            EnterpriseSession ceSession = EntSession;

            EnterpriseService ceEnterpriseService;
            InfoStore ceInfoStore;
            CrystalDecisions.Enterprise.InfoObjects ceReportObjects;
            CrystalDecisions.Enterprise.InfoObject ceReportObject;
            Report ceReport;
            string sQuery;
            try
            {
                //grab the Enterprise session
                if (ceSession != null)
                {
                   // ceSession = (EnterpriseSession)Session["ceSession"];

                    //Create the infostore object
                    ceEnterpriseService = ceSession.GetService("", "InfoStore");
                    ceInfoStore = new InfoStore(ceEnterpriseService);

                    //Create query to grab the desired report
                    sQuery = "Select top 1 SI_ID, SI_PROCESSINFO.SI_PROMPTS,* From CI_INFOOBJECTS Where  SI_ID=" + _reportId + " AND SI_INSTANCE=0 ";
                    ceReportObjects = ceInfoStore.Query(sQuery);

                    //check for returned reports
                    if (ceReportObjects.Count > 0)
                    {
                        ceReportObject = ceReportObjects[1];

                        //ceReport = (Report)ceReportObject;

                        //Create an interface to the scheduling options for the report.
                       CrystalDecisions.Enterprise.SchedulingInfo ceSchedulingInfo;
                        ceSchedulingInfo = ceReportObject.SchedulingInfo;
                        //run the report right now
                        ceSchedulingInfo.RightNow = true;
                        //run the report once only
                        ceSchedulingInfo.Type = CeScheduleType.ceScheduleTypeOnce;

                        //When scheduling to all destinations except the printer, you must first retrieve 
                        //the appropriate destination object. Each destination InfoObject is stored in the 
                        //CMS system table (CI_SYSTEMOBJECTS) under the Destination Plugins folder

                        //Retrieve the DiskUnmanaged Plugin from CI_SYSTEMOBJECTS
                      CrystalDecisions.Enterprise.InfoObjects ceDestinationObjects;
                      CrystalDecisions.Enterprise.InfoObject ceDestinationObject;
                        ceDestinationObjects = ceInfoStore.Query("Select * from CI_SYSTEMOBJECTS Where SI_NAME = 'CrystalEnterprise.DiskUnmanaged'");
                        ceDestinationObject = ceDestinationObjects[1];
                        //ReportFormatOptions ceReportFormatOpts;
                        //ceReportFormatOpts = ceReportObject.ReportFormatOptions;


                        //Create the DestinationPlugin object
                        DestinationPlugin ceDisk = new DestinationPlugin(ceDestinationObject.PluginInterface);



                        DiskUnmanagedOptions ceDiskOpts = new DiskUnmanagedOptions(ceDisk.ScheduleOptions);

                        ceDiskOpts.DestinationFiles.Add(@"" + Utility.BO.BOReportFolder + DateTime.Now.ToString("yyyy_MM_dd") + "_" + ceReportObject.Title.ToString() + ".pdf");

                        CrystalDecisions.Enterprise.Destination ceDestination;
                        ceDestination = ceSchedulingInfo.Destination;
                        ceDestination.SetFromPlugin(ceDisk);
                        List<string> reportParameterList = new List<string>();


                        Report rpt = ceReportObject as Report;
                        if (rpt != null)
                        {
                            //for each (CrystalDecisions.Enterprise.Desktop.Internal.ISReportParameter parameter in (CrystalDecisions.Enterprise.Desktop.Internal.ISReportParameter)rpt.ReportParameters)
                            //{
                            //    reportParameterList.Add(new ReportParameter(parameter));
                            //}
                            for (int i = 0; i < rpt.ReportParameters.Count; i++)
                            {
                                rpt.ReportParameters[i].DefaultValues[0].SingleValue.Value = "";
                               // ISReportParameter isp =(ISReportParameter) rpt.ReportParameters[i];
                               // reportParameterList.Add(rpt.ReportParameters[i].ToString());
                            }
                        }




                        //ReportParameters ceParameters;
                        //ReportParameterValue ceParamValue;
                        //ReportParameters rpt = ceReportObject as ReportParameters ;

                        //if (rpt != null)
                        //{


                        //    //ceParameters = ((Report)ceReportObject).ReportParameters;
                        //    foreach (ReportParameter ceParameter in rpt.ReportParameters)
                        //    {
                        //        ceParamValue = ceParameter.CreateSingleValue();
                        //        // ceParamValue.SingleValue.Value = "Time(12,15,15)";
                        //        //ceParameter.CurrentValues.Add(ceParamValue);
                        //    }
                        //}



                        //schedule report
                        ceInfoStore.Schedule(ceReportObjects);

                        return "Report Scheduled Successfully with an Object ID of : " + ceDestinationObject.ID.ToString()
                         + "<br>Report Scheduled to the following location: " + ceDiskOpts.DestinationFiles[1].ToString();
                    }

                }
                else
                {
                    //no Enterprise session available
                    return ("No Valid Enterprise Session Found!<br>"
                    + "Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>");
                }
            }
            catch (Exception err)
            {
                throw new Exception(
                "There was an error scheduling the report: <br>" +
                err.Message.ToString() + "<br>" +
                "Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>");
            }
            return "";
        }

请帮助将参数传递给WEBI报告。

1 个答案:

答案 0 :(得分:1)

我得到了SAP团队的回复

在BI4.0中,不推荐使用ReportEngine来安排带有提示的webi报告,替换解决方案是RESTful Web Service SDK。 您可以在链接中查看详细说明:https://blogs.sap.com/2014/03/13/migration-guide-for-businessobjects-enterprise-sdk-custom-applications/

关于RESTful Web Service SDK,您可以在此链接中找到更多有用的信息:https://archive.sap.com/documents/docs/DOC-51800