BusinessObjects Board

How to print report on Crystal Enterprise server from .Net?

We want our Crystal Enterprise server to print a report. The request to print will come from a .Net web app that we’re building.

We’ve tried all kinds of combinations of SAP DLLs and Visual Studio settings without success.

What DLLs should we reference? Where can we download these DLLs? Please provide a URL if possible – we have an active SAP license so we can access the download – we just don’t know which one to use.

Should we reference these DLLs from the GAC (on the dev machine and on the production server), or should we copy them to the project’s bin directory?

Also, we haven’t been able to located any SDK docs for this issue. Any URLs to docs would be fantastic.

We’re using:

  •      Crystal Enterprise (v14, I think, but not sure where to check)
    
  •      Visual Studio 2015
    
  •      .Net 4.62
    
  •      We’ve tried Platform target x86, x64, and Any CPU (we strongly prefer x64, if possible)
    

Here is the source code we’re attempting to use, based on the samples we could find on the SAP sites. Any recommendations for changes are appreciated.

           
            string boAPS = "INTERNAL IPv4 ADDRESS REDACTED";
            string boUserID = "CE10";
            string boPassword = "PASSWROD REDACTED";
            string boAuthorization = "secEnterprise";
            string boReportName = "rptAPInvoiceListWithDistrib";
            string boQuery = "SELECT * FROM CI_INFOOBJECTS WHERE SI_ProgId = 'CrystalEnterprise.Report'" +
                " AND SI_NAME = '" + boReportName + "'" +
                " AND prompt0="  + manifest.ManifestNumber + "'";

            CrystalDecisions.Enterprise.EnterpriseSession boEnterpriseSession;
            CrystalDecisions.Enterprise.InfoObject boInfoObject;
            CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument boReportClientDocument;

            CrystalDecisions.Enterprise.SessionMgr boSessionMgr;
            CrystalDecisions.Enterprise.InfoStore boInfoStore;
            CrystalDecisions.Enterprise.EnterpriseService boEnterpriseService;
            CrystalDecisions.Enterprise.InfoObjects boInfoObjects;
            CrystalDecisions.ReportAppServer.ClientDoc.ReportAppFactory boReportAppFactory;

            //Log on to the Enterprise CMS
            boSessionMgr = new CrystalDecisions.Enterprise.SessionMgr();
            boEnterpriseSession = boSessionMgr.Logon(boUserID, boPassword, boAPS, boAuthorization);
            Session.Add( "boEnterpriseSession", boEnterpriseSession );
            boEnterpriseService = boEnterpriseSession.GetService("", "InfoStore");
            boInfoStore = new CrystalDecisions.Enterprise.InfoStore(boEnterpriseService);

            //Retrieve the report object from the InfoStore, only need the SI_ID for RAS
            boInfoObjects = boInfoStore.Query(boQuery);
            boInfoObject = boInfoObjects[1];

            boEnterpriseService = null;

            //Retrieve the RASReportFactory
            boEnterpriseService = boEnterpriseSession.GetService("RASReportFactory");
            boReportAppFactory = (CrystalDecisions.ReportAppServer.ClientDoc.ReportAppFactory)boEnterpriseService.Interface;
            //Open the report from Enterprise
            boReportClientDocument = boReportAppFactory.OpenDocument(boInfoObject.ID, 0);

            boReportClientDocument.PrintOutputController.ModifyPrinterName(@"\\van-s-prt01\VAN-P-OLYMPIA");

            //Print the report.
            boReportClientDocument.PrintOutputController.PrintReport(null);

MrE (BOB member since 2017-05-18)

Download the client SDK from SAP.

You should see them in VS when Add Reference under extensions. They will have vesion numbers. Set the properties to copy local. The file version shows the actual BO(crystal) version.

I haven’t been able to use Any CPU. So, in my project I use x86


sijaffe (BOB member since 2017-06-06)

Hi MrE,

Did you resolved your problem ?
because I have exactly the same and for the moment I really don’t know how to do.

I’m using
Visual Studio 2017
BOE 4.2
Crystal Report 2016 … CrystalDecision version 14.0.2000.0

Thank you very much for you quick feedback


drayafxela (BOB member since 2017-11-23)