on 10-02-2013 8:25 PM
Hi All,
I searched a lot in forums and even found a SAP manual on the integration between VB 6 and Crystal XI.
In all instances, passing parameters to Crystal via VB is made one by one (knowing the exact name of the report, the expected parameters and the exact values that should be passed).
Using Session and links in the examples, they added the links between the main report and the subs manually one by one.
In my case, I have a structure that worked with Crystal 8.5, using SubreportToChange smoothly.
I have some generic routines that feed the reports and I need to automate this routine for CR XI.
However, I have not found a simple way to do this, as was done previously.
Once the links are made by the design of the report, how to use them in my application without having to redo these links in the code?
Or how to do this in a dynamic and generic way?
Grateful.
Hello Leonardo
First thing you need to do is upgrade to CR XI R2 (11.5). You can do that by following the instruction in this blog.
The install will also give you developer help files and I'd recommend looking at those. The dev files will be in:
C:\Program Files\Business Objects\Crystal Reports 11.5\Help\en\crsdk_samples_aspx\data\crsdk_net_tutorials_115_en.zip
C:\Program Files\Business Objects\Crystal Reports 11.5\Help\en\crsdk_net_doc\doc\crsdk_net_doc.chm
I am not entirely sue I understand the issue, so look in the help files, look at the samples here:
http://wiki.scn.sap.com/wiki/x/WABmBQ
and try the search box in the top right of this web page.
If none of the above help, can you restate the problem?
Oh, BTW, neither CR XI, not CR CI R2 are supported anymore.
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
Got Enhancement ideas? Try the SAP Idea Place
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First of all, thanks for the feedback.
My version is already the R2 .
For information, I'm still updating the Crystal version of the system in VB 6.0 because there is a bug in cents to export reports .
The first time you export the report , everything happens correctly . But the second time , all out 0.00 cents .
After searching a lot, I read that the R2 version solves this problem.
The problem now is that all the examples I see , has the names of subreports and parameters manually flagged .
I have a generic routine that works in VB 6.0 with Crystal 8.5 , which independent report has or has not sub , it resolves itself ... with only one line of
code :
iTotSubRel = goReport.GetNSubreports
For i = 0 To iTotSubRel - 1
goReport.SubreportToChange = goReport.GetNthSubreportName (i )
goReport.Connect = MSA_Declarations.gdbConnect.gdbConnection.Connect
Next i
The example I have in the folder of Crystal R2 is this :
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
Inherits System.Windows.Forms.Form
The Private customersByCityReport CustomersByCity
Private Const PARAMETER_FIELD_NAME As String = " City "
Private Const SUBREPORT_PARAMETER_FIELD_NAME As String = " OrderDateRange "
Private Const SUBREPORT_NAME As String = " CustomerOrders "
# Region " Windows Form Designer generated code "
Public Sub New ( )
MyBase.New ( )
'This call is required by the Windows Form Designer .
InitializeComponent ( )
ConfigureCrystalReports ()
'Add any initialization after the InitializeComponent ( ) call
end Sub
' Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )
If disposing Then
If Not ( components Is Nothing ) Then
components.Dispose ()
end If
end If
MyBase.Dispose (disposing )
end Sub
' Required by the Windows Form Designer
The Private components System.ComponentModel.IContainer
' NOTE : The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer .
' Do not modify it using the code editor .
Friend WithEvents myCrystalReportViewer The CrystalDecisions.Windows.Forms.CrystalReportViewer
Friend WithEvents defaultParameterValuesList The System.Windows.Forms.ListBox
The System.Windows.Forms.Button Friend WithEvents redisplay
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent ( )
Me.myCrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Me.defaultParameterValuesList = New System.Windows.Forms.ListBox
Me.redisplay = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.orderStartDate = New System.Windows.Forms.TextBox
Me.orderEndDate = New System.Windows.Forms.TextBox
Me.SuspendLayout ()
'
' myCrystalReportViewer
'
Me.myCrystalReportViewer.ActiveViewIndex = -1
Me.myCrystalReportViewer.Anchor = CType ( ( ( ( Or System.Windows.Forms.AnchorStyles.Top System.Windows.Forms.AnchorStyles.Bottom ) _
Or System.Windows.Forms.AnchorStyles.Left ) _
Or System.Windows.Forms.AnchorStyles.Right ) System.Windows.Forms.AnchorStyles )
Me.myCrystalReportViewer.Location = New System.Drawing.Point ( 0 , 126 )
Me.myCrystalReportViewer.Name = " myCrystalReportViewer "
Me.myCrystalReportViewer.ReportSource = Nothing
Me.myCrystalReportViewer.Size = New System.Drawing.Size ( 592 , 352 )
Me.myCrystalReportViewer.TabIndex = 0
'
' defaultParameterValuesList
'
Me.defaultParameterValuesList.Location = New System.Drawing.Point ( 8 , 8 )
Me.defaultParameterValuesList.Name = " defaultParameterValuesList "
Me.defaultParameterValuesList.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended
Me.defaultParameterValuesList.Size = New System.Drawing.Size (120, 95)
Me.defaultParameterValuesList.TabIndex = 1
'
' redisplay
'
Me.redisplay.Location = New System.Drawing.Point ( 144 , 80 )
Me.redisplay.Name = " redisplay "
Me.redisplay.Size = New System.Drawing.Size ( 144 , 23 )
Me.redisplay.TabIndex = 2
Me.redisplay.Text = " Redisplay Report"
'
' Label1
'
Me.Label1.Location = New System.Drawing.Point (152 , 16)
Me.Label1.Name = " Label1 "
Me.Label1.TabIndex = 3
Me.Label1.Text = "Order Start Date "
'
' Label2
'
Me.Label2.Location = New System.Drawing.Point ( 152 , 48 )
Me.Label2.Name = " Label2 "
Me.Label2.TabIndex = 4
Me.Label2.Text = "Order End Date"
'
' orderStartDate
'
Me.orderStartDate.Location = New System.Drawing.Point (272 , 16)
Me.orderStartDate.Name = " orderStartDate "
Me.orderStartDate.TabIndex = 5
Me.orderStartDate.Text = " "
'
' orderEndDate
'
Me.orderEndDate.Location = New System.Drawing.Point ( 272 , 48 )
Me.orderEndDate.Name = " orderEndDate "
Me.orderEndDate.TabIndex = 6
Me.orderEndDate.Text = " "
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 )
Me.ClientSize = New System.Drawing.Size ( 592 , 478 )
Me.Controls.Add ( Me.orderEndDate )
Me.Controls.Add ( Me.orderStartDate )
Me.Controls.Add ( Me.Label2 )
Me.Controls.Add ( Me.Label1 )
Me.Controls.Add ( Me.redisplay )
Me.Controls.Add ( Me.defaultParameterValuesList )
Me.Controls.Add ( Me.myCrystalReportViewer )
Me.Name = " Form1 "
Me.Text = " Form1 "
Me.ResumeLayout ( False )
end Sub
# End Region
Private Sub ConfigureCrystalReports ()
New CustomersByCity customersByCityReport = ( )
Dim myArrayList The ArrayList = New ArrayList ( )
myArrayList.Add ( " Paris " )
myArrayList.Add ( " Tokyo " )
Dim startDate As String = " 8/1/2004 "
orderStartDate.Text startDate =
Dim endDate As String = " 08/31/2004 "
orderEndDate.Text = endDate
defaultParameterValuesList.DataSource = GetDefaultValuesFromParameterField ( customersByCityReport )
SetCurrentValuesForParameterField ( customersByCityReport , myArrayList )
SetDateRangeForOrders ( customersByCityReport , startDate , endDate )
myCrystalReportViewer.ReportSource = customersByCityReport
end Sub
Private Sub SetCurrentValuesForParameterField ( ByVal myReportDocument The ReportDocument , ByVal myArrayList The ArrayList )
Dim currentParameterValues The New ParameterValues ParameterValues = ( )
As Object Dim submittedValue
For Each submittedValue In myArrayList
Dim myParameterDiscreteValue The New ParameterDiscreteValue ParameterDiscreteValue = ( )
myParameterDiscreteValue.Value submittedValue.ToString = ()
currentParameterValues.Add ( myParameterDiscreteValue )
Next
Dim myParameterFieldDefinitions The ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
Dim myParameterFieldDefinition The ParameterFieldDefinition = myParameterFieldDefinitions ( PARAMETER_FIELD_NAME )
myParameterFieldDefinition.ApplyCurrentValues ( currentParameterValues )
end Sub
Private Function GetDefaultValuesFromParameterField ( ByVal myReportDocument The ReportDocument ) The ArrayList
Dim myParameterFieldDefinitions The ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
Dim myParameterFieldDefinition The ParameterFieldDefinition = myParameterFieldDefinitions ( PARAMETER_FIELD_NAME )
Dim defaultParameterValues The ParameterValues = myParameterFieldDefinition.DefaultValues
Dim myArrayList The ArrayList = New ArrayList ( )
Dim myParameterValue The ParameterValue
For Each myParameterValue In defaultParameterValues
If ( Not myParameterValue.IsRange ) Then
Dim myParameterDiscreteValue The ParameterDiscreteValue = CType ( myParameterValue , ParameterDiscreteValue )
myArrayList.Add ( myParameterDiscreteValue.Value.ToString ())
end If
Next
return myArrayList
end Function
The System.Windows.Forms.TextBox Friend WithEvents orderEndDate
The System.Windows.Forms.TextBox Friend WithEvents orderStartDate
The System.Windows.Forms.Label Friend WithEvents Label2
The System.Windows.Forms.Label Friend WithEvents Label1
Private Sub redisplay_Click ( ByVal sender As System.Object , ByVal e As System.EventArgs ) Handles redisplay.Click
Dim myArrayList The ArrayList = New ArrayList ( )
Dim item As String
For Each item In defaultParameterValuesList.SelectedItems
myArrayList.Add ( item)
Next
SetCurrentValuesForParameterField ( customersByCityReport , myArrayList )
Dim startDate As String = orderStartDate.Text
Dim endDate As String = orderEndDate.Text
SetDateRangeForOrders ( customersByCityReport , startDate , endDate )
myCrystalReportViewer.ReportSource = customersByCityReport
end Sub
Private Sub SetDateRangeForOrders ( ByVal myReportDocument The ReportDocument , ByVal startDate As String , ByVal endDate As String )
Dim myParameterRangeValue The New ParameterRangeValue ParameterRangeValue = ( )
myParameterRangeValue.StartValue startDate =
myParameterRangeValue.EndValue = endDate
myParameterRangeValue.LowerBoundType = RangeBoundType.BoundInclusive
myParameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive
Dim myParameterFields The ParameterFields = myReportDocument.ParameterFields
Dim myParameterField The ParameterField = myParameterFields ( SUBREPORT_PARAMETER_FIELD_NAME , SUBREPORT_NAME )
myParameterField.CurrentValues.Clear ()
myParameterField.CurrentValues.Add ( myParameterRangeValue )
end Sub
end Class
I do all the links between the report and its subs visually by Crystal.
Some examples, from what I understand, require me to redo these links by code in VB 6.0.
All attempts I've tried so far, make a screen shoot for the subreport parameters are entered.
I am unsure what to do at the moment.
Very grateful!
Hi Leonardo,
Are you updating the CR 8.5 reports manually also? The database drivers have been renamed and they have changed so the issue may be the old reports need to be updated in CR Designer first.
Does a new report have the same issue?
Also, CR 8.5 is not side by side supported, if you have 8.5 on the same PC you need to uninstall it and rename c:\windows\crystal to \CrystalOld as well delete/rename crpe32.dll located in c:\windows\system32 fodler.
Don
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.