Kbase P71413: How to pass parameters to the Crystal Reports 9 Runtime Engine with 4GL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  28/03/2008 |
|
Status: Verified
GOAL:
How to pass parameters to the Crystal Reports 9 Runtime Engine with 4GL?
GOAL:
How to pass parameters to a Crystal report?
GOAL:
How to control the output of a report using parameters with the Crystal Reports 9 runtime engine and 4GL?
FACT(s) (Environment):
Progress 8.3E
Progress 9.1D
Crystal Reports 9
All Supported Operating Systems
FIX:
This sample was tested with Crystal Reports 9. The report was created against the Sports2000 database and allowed orders to be displayed on the basis of CustNum supplied by the user.
1) Insert the Crystal Report Viewer Control into a window.
2) Create a Fill-In field (in the sample code, this is fCustNum). Please note that the value must be converted to match the datatype of the parameter defined in the report, hence the INT(fCustNum:SCREEN-VALUE).
3) Add a button and copy the following code into the CHOOSE trigger.
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO.
CREATE 'CrystalRuntime.Application' chApplication.
CREATE 'CrystalRuntime.Report' chReport.
/* Enter details of your ODBC connection here */
chApplication:LogOnServer("p2sodbc.dll", "<ODBC DSN Name>", "", "<Username>", "<Password>").
/* Insert full path to the Crystal report */
chReport = chApplication:OpenReport("<FullPathToReport>").
/* Clears current value of parameter */
chReport:ParameterFields:ITEM(1):ClearCurrentValueAndRange().
/* Sets new value of parameter */
chReport:ParameterFields:ITEM(1):SetCurrentValue(INT(fCustNum:SCREEN-VALUE)).
/* Enables the CRViewer's Navigation Controls */
chCtrlFrame:CRViewer9:EnableNavigationControls = TRUE.
/* Enables the CRViewer's Group Tree */
chCtrlFrame:CRViewer9:DisplayGroupTree = FALSE.
/* Enables the CRViewer's Export button */
chCtrlFrame:CRViewer9:EnableExportButton = TRUE.
/* Disables the CRViewer's Search control */
chCtrlFrame:CRViewer9:EnableSearchControl = FALSE.
/* Set the report source */
chCtrlFrame:CRViewer9:ReportSource = chReport.
/* View the report */
chCtrlFrame:CRViewer9:ViewReport().
RELEASE OBJECT chApplication.
RELEASE OBJECT chReport.