Steps for implementing Crystal Report Viewer XI and dynamic

Posted by adisney on 23-Mar-2010 18:37

Our solution (after 2 years of struggle) for using Crystal Report Viewer XI with a dynamic XML data source, without requiring a full Crystal Developer install on each client machine (very pricey):

  • Install Java, if not already installed (check c:\program files\java)
    • Go to www.google.com and search for "java download"
    • The first result should be www.java.com/getjava
    • Select the Downloads subheading
    • Find and select the appropriate download for your machine (e.g. Windows 2003 32 bit)
    • Press the "Run" button if a security warning pops up and asks if youw ant to save
    • Follow the prompts in the installer
  • Install Crystal Reports Runtime
  • Go to http://www.bionreports.eu/download/DeployCR11.zip This is a special .msi which contains .dll files which are on the Report Viewer CD, but not in the Report Viewer download. This is because they are dependent on a java installation, and Business Objects (the Crystal company) doesn't want any java-dependent DLL files in a download).
  • Save (dialog may be behind your web-browser) and unzip the file, then run DeployCR11.msi (note: the install directory seems to be overwritten by C:/Program Files/Business Objects/ which is fine)
  • Create a "java" directory in C:\Program Files\Business Objects\Common\3.5\
  • Make sure your Progress code is all in place, including the programs which produce the .xml/.xsd files and the program which calls the Crystal Report Viewer (our code for this included below).
  • Make sure your Crystal Report, a .rpt file, is in the correct directory; whatever one your code will expect. It doesn't need to have saved data.
  • Copy files around
  • Copy the directory C:\Program Files\Crystal\Common\3.5\java\lib from your development machine to the same directory on the client machine where you are deploying Crystal (note: sometimes the "Crystal" directory may be "Business Objects" instead, and if it a 64 bit machine then the client machine will be C:\Program Files (x86)\ instead of C:\Program Files\). This step was obtained from the Business Objects website, so we assume it's kosher. See http://www.sdn.sap.com/irj/scn/weblo.../pub/wlg/13732
  • Copy the C:\Program Files\Business Objects\Common\3.5\java\CRConfig.xml file from the development machine to the same location on the client machine. This step was also obtained from the Business Objects site
  • Copy the crdb_xml.dll and crdb_xml_rex_en.dll files from the C:\Program Files\Business Objects\Common\3.5\bin\ directory on the development machine to the same directory on the client machine. This step was also obtained from the Business Objects site.
  • Edit the C:\Program Files\Business Objects\Common\3.5\java\CRConfig.xml file on the client machine
  • Select the file, right click and select edit (or, if you do not have that option, open it with notepad)
  • Change the JavaDir entry to the java location on the client machine (C:\Program Files\java\jre[version info]\bin)
  • Change the Classpath entry to correctly point all the .jar files to the directory C:\Program Files\Crystal\Common\3.5\java\lib\
  • Test!

Attached is our Progress code for calling the Report Viewer. You may need to modify it considerably. There would be an associated .wrx, created by inserting as an OCX C:\Program Files (x86)\Business Objects\Common\3.5\crystalreportviewers115\ActiveXControls\CRViewer.dll [or the equivalent for your installation]

Hopefully this will help someone. We had a huge amount of help with this from Ionut Balas (balasionut@gmail.com) who is a Romanian freelancer who doesn't know much about Progress but is Crystal guru. He says that he is open to providing others with assistance.

Core of the viewer program is this:

/*------------------------------------------------------------------------------

  Purpose: Take an .rpt, .xml, and .xsd file and display a Crystal report.

  Notes: 

------------------------------------------------------------------------------*/

   /* already defined in definitions section:


   /* com-handles to the various objects necessary to open a Crystal report */
   define variable chApplication as com-handle no-undo.
   define variable chViewer      as com-handle no-undo.
   define variable chReport      as com-handle no-undo.
   define variable chTable       as com-handle no-undo.

   */

   */

  

   define variable counter as integer    no-undo.

   define variable lv-data as character  no-undo.

   /* get the full path for the rpt and xml/xsd files */

   file-info:filename = pv-report.

   pv-report = file-info:full-pathname.

   file-info:filename = pv-data.

   pv-data = file-info:full-pathname.

   /* set a string that indicates the location and names of the xml and xsd

      files */

   lv-data =

      "Local XML File="    + pv-data + ";" +

      "Local Schema File=" + entry(1,pv-data,".") + ".xsd".

   /* create an instance of the Crystal runtime */

   create "CrystalRuntime.Application" chApplication.

   /* open a report in the Crystal runtime */

   chReport = chApplication:OpenReport(pv-report,1).

   /* get rid of any data that was saved with the report */

   chReport:DiscardSavedData().

   /* if this report has a table, then set its connection string and location */

   if chReport:Database:Tables:Count > 0 then do:

       /* set the connection string on the first table to the xml and xsd

          files */

       chReport:Database:Tables(1):ConnectBufferString = (lv-data).

      /* loop through the tables in the report (this includes subtables),

         setting each ones location (the location of the xml and xsd files) */

      do counter = 1 to chReport:Database:Tables:Count:

         /* get a com-handle to the current table */

         chTable = chReport:Database:Tables(counter).

         /* if the table uses an xml as a datasource, then set its table

            location to the xml and xsd that was passed in */

         if chTable:DecriptiveName = "XML" then

            chTable:SetTableLocation(

               chTable:Location, /* name of table */

               "",               /* not sure what this parameter is */

               lv-data).         /* the datasource connection string */

      end. /* loop through tables */

   end. /* report has a table */

   /* read in records from the datasource to the report */

   chReport:ReadRecords().

   /* set some attributes on the Crystal report viewer, and then view the

      report */

   chViewer:DisplayTabs  = false.

   chViewer:ReportSource = chReport.

   chViewer:ViewReport().

end procedure.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/crystalviewer.w.zip:550:0]

All Replies

This thread is closed