Kbase P104000: How to list the parameter fields of the ParameterFieldDefinitions Collection of a Crystal Report obj
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  28/03/2008 |
|
Status: Verified
GOAL:
How to list the parameter fields of the ParameterFieldDefinitions Collection of a Crystal Report object using 4GL?
FACT(s) (Environment):
OpenEdge 10.x
Crystal Reports 10
All Supported Operating Systems
FIX:
This solution uses the ParameterFields property of the report object to get the handle of the reports ParameterFieldDefinitions Collection. It then uses the COUNT and the ITEM properties of the ParameterFieldDefinitions Collection to access the individual ParameterFieldDefinition Objects. It further accesses a host of information using several properties of the ParameterFieldDefinition object:
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chParameterFields AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DEFINE VARIABLE iNumParameters AS INTEGER NO-UNDO.
CREATE 'CrystalRuntime.Application' chApplication.
CREATE 'CrystalRuntime.Report' chReport.
/* Enter details of your ODBC connection here */
chApplication:LogOnServer("crdb_odbc.dll", "Sports2000", "", "username", "password").
/* Insert full path to the Crystal report */
chReport = chApplication:OpenReport("C:\OpenEdge\WRK100B\CustomerOrders.rpt").
/* Get the handle of the report ParameterFields collection */
chParameterFields = chReport:ParameterFields.
/* Get number of parameters in the ParameterFields collection */
iNumParameters = chParameterFields:COUNT.
MESSAGE "The number of parameters in this report is: " "~t" iNumParameters
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* Loop through the collection and message the name of each parameter field */
DO iCounter = 1 TO iNumParameters:
MESSAGE
"The displayed name of the parameter field: " "~t" chParameterFields:ITEM(iCounter):ParameterFieldName "~n"
"The Parameter Type (0=report, 1 = query 2 = Stored procedure: " "~t" chParameterFields:ITEM(iCounter):ParameterType "~n"
"Crystal Reports Field Value Type: " "~t" chParameterFields:ITEM(iCounter):ValueType "~n"
"The unique formula name of the field : " "~t" chParameterFields:ITEM(iCounter):NAME "~n"
"Gets which kind of field (database, summary, formula, etc.).: " "~t" chParameterFields:ITEM(iCounter):kind "~n"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
RELEASE OBJECT chApplication.
RELEASE OBJECT chReport.
RELEASE OBJECT chParameterFields.