Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Web service appears to be ignoring values for destination and parameters.

I'm on my long trek trying to get a report to export programatically from CRS2008 to a pdf in a folder. The good news is I'm almost done. The bad news is I can't seem to figure out where I'm going wrong. I've cobbled together some code and it works (doesn't die). The only problem is whatever I set the destination to be it always gets overridden by the defaults in the report. The same goes for the parameters.

Any help would be greatly appreciated,

J

code is below.

    protected void TestSub2()
    {
        // Document path
        string crPath = "path://InfoObjects/Root Folder/WWE Reports/rtodbc3" + "@SI_SCHEDULEINFO,SI_PROCESSINFO";
        // Enterprise Web Services URL and Login Credentials.
        string boSessionURL = "http://192.168.1.100:8080/dswsbobje/services/Session";

        string boCMSName = "myorgani-1cf481";

        string boAuthType = "secEnterprise";
        string boUsername = "Administrator";
        string boPassword = "Password";

        Session boSession = null;
        try
        {
            // Logon to Enterprise

            EnterpriseCredential boCredential = new EnterpriseCredential();
            boCredential.Domain = boCMSName;
            boCredential.AuthType = boAuthType;
            boCredential.Login = boUsername;
            boCredential.Password = boPassword;

            boSession = new Session(new BusinessObjects.DSWS.Connection(boSessionURL));
            boSession.Login(boCredential);

            // Retrieve Document CUID

            BIPlatform biPlatform
                = BIPlatform.GetInstance(boSession, boSession.GetAssociatedServicesURL("BIPlatform")[0]);

            GetOptions getOpts = new GetOptions();
            getOpts.IncludeSecurity = true;

            ResponseHolder rh = biPlatform.Get(crPath, getOpts);

            InfoObjects reports = rh.InfoObjects;

            if (reports == null)
            {
                return;
            }

            BusinessObjects.DSWS.BIPlatform.Desktop.CrystalReport myReport = (BusinessObjects.DSWS.BIPlatform.Desktop.CrystalReport)reports.InfoObject[0];
            SchedulingInfo schedulingInfo = myReport.SchedulingInfo;
            if (schedulingInfo == null)
            {
                schedulingInfo = new SchedulingInfo();
            }

            //start put in parameters
            ReportProcessingInfo procInfo = myReport.PluginProcessingInterface;
            ReportParameter[] repParams = procInfo.ReportParameters;
            CurrentValues oCurrentValues = new CurrentValues();
            BusinessObjects.DSWS.BIPlatform.Desktop.PromptValue[] oPromptValue = new BusinessObjects.DSWS.BIPlatform.Desktop.PromptValue[1];
            oPromptValue[0] = new BusinessObjects.DSWS.BIPlatform.Desktop.PromptValue();
            oPromptValue[0].Data = "2";
            oCurrentValues.CurrentValue = oPromptValue;
            repParams[0].CurrentValues = oCurrentValues;
            // end put in parameters

            //start put in for scheduling parameters...
            Destination[] oDestination = new Destination[1];
            oDestination[0] = new Destination();
            oDestination[0].Name = "CrystalEnterprise.DiskUnmanaged";
            BusinessObjects.DSWS.BIPlatform.Dest.DiskUnmanagedScheduleOptions diskOptions = new BusinessObjects.DSWS.BIPlatform.Dest.DiskUnmanagedScheduleOptions();
            String[] destinationFile = new String[1];
            destinationFile[0] = "C:\\" + myReport.Name + ".rpt";
            diskOptions.DestinationFiles = destinationFile;
            schedulingInfo.Destinations = oDestination;
            //end put in for scheduling parameters...

            schedulingInfo.RightNow = true;
            schedulingInfo.ScheduleType = ScheduleTypeEnum.ONCE;

            BusinessObjects.DSWS.BIPlatform.Desktop.ReportProcessingInfo reportProcessingInfo = new ReportProcessingInfo();
            BusinessObjects.DSWS.BIPlatform.Desktop.CrystalReportFormatOptions crystalReportFormatOptions;

            crystalReportFormatOptions = new CrystalReportFormatOptions();
            crystalReportFormatOptions.Format = ReportFormatEnum.PDF;
            crystalReportFormatOptions.FormatSpecified = true;

            reportProcessingInfo.ReportFormatOptions = crystalReportFormatOptions;
            myReport.PluginProcessingInterface = reportProcessingInfo;
            myReport.SchedulingInfo = schedulingInfo;
            reports.InfoObject[0] = myReport;

            biPlatform.Schedule(reports);

            Response.Write("hey it worked!");

        }
        catch (DSWSException ex)
        { Console.WriteLine(ex); }
        finally
        {

            if (boSession != null)
                boSession.Logout();

        }
    }

Not what you were looking for? View more on this topic or Ask a question