This section describes how to add a report to Crystal Enterprise. The example that is included consists of two CSP files. The first file(GetReportDetails.csp) prompts the user for the path and filename of the report to be added. The second file (AddReport.csp) adds the report to the File Repository Server in the specified folder.
This section only demonstrates how to add a report that is already on the web server. For details on how to transfer a file from a client machine to the web server using a browser, see your web server documentation.
Note: As an alternative to using CSP files to add a report, you may also use the Report Publishing Wizard.
The following parts in this section explain how to add a report in general, demonstrates this procedure using code, and finally provides a working example.
The following procedure assumes you have already logged onto the APS and have a current session (see Authenticating and logging on the user for information on creating a session):
The PluginManager allows you to retrieve the Report plugin, which is needed to create a report object.
The InfoObjects Add method creates a new InfoObject based on the type of plugin you give it. In this case, it creates a new Report object and adds it to the collection. It is important to note that a report object is a type of InfoObject.
The report data may be specified in the form of a path and filename, or in a binary stream format that contains the report data. If a path is specified it must be a path on the web server. In the case where the Web Component Server (WCS) is not running on the same machine as the web server, this path points to a location on the WCS. You do not, however, have to be concerned with transferring the file from the web server to the WCS. This is handled for you by Crystal Enterprise. For information on transferring the file from a browser to the web server, refer to your web server documentation.
The folder into which the report is to be placed is set using the report's parent ID. If the ID is zero or the ID does not belong to a folder, the report will not be added; otherwise it is placed in the folder specified by the SI_PARENTID Property.
This adds the report to the File Repository Server and updates the APS InfoStore.
These steps are illustrated in the following function:
function AddReport(FolderID, ReportName, InfoStore)
' Adds a report to a particular folder.
' The ID of the folder which will contain the report.
' The full path and filename of the report.
' The InfoStore used to communicate with the server.
' Returns the ID of the newly added report.
' If the function fails, it returns zero.
' Since reports are implemented using a plugin
' you will need the PluginManager to retrieve the Report plugin.
set pmgr = InfoStore.PluginManager
' Retrieve the Report plugin by passing the pluginís ProgID
' to the PluginInfo property of the PluginManager.
set ReportPlugin = pmgr.PluginInfo("CrystalEnterprise.Report")
' Create a new, empty InfoObject collection.
set NewCollection = InfoStore.NewInfoObjectCollection()
' Give the Report plugin object to the Add method. This
' creates a new InfoObject based on the plugin type.
' In this case, since the plugin is the Report plugin,
' the object created is a report object. The new report object
' is added to the empty collection.
set NewReport = NewCollection.Add(ReportPlugin)
' Add the report data to the Files Collection. Do this using
' the collectionís Add method. The report data may be specified
' in the form of a path and filename, or in a binary stream format
' that contains the report data. If a path is specified it must be
call NewReport.Files.Add (ReportName)
' The next line indicates where in the folder tree the
' report is to be added. It does this by setting the
' parent ID property or, in other words, by telling the report
' which folder it is to be placed in. If the parent ID property is
' zero, the report will not be committed properly. If the parent ID
' is not a folder, the report will not be committed properly.
call NewReport.Properties.Add ("SI_PARENTID",FolderID)
' Retrieve the report's interface and try to enable
set ireport = NewReport.PluginInterface
ireport.EnableThumbnail = true
' Use the InfoStore to commit the new collection with the new report
call InfoStore.Commit (NewCollection)
' There was an error so return 0.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |