SAP Knowledge Base Article - Public

1215460 - How to pass a parameter to a subreport at runtime using RAS and .NET

Symptom

A Microsoft Visual Studio .NET (VS .NET) application uses the Report Application Server (RAS) as the reporting development tool.

 

A report contains a subreport that requires a parameter value. How do you pass a parameter value to a subreport at runtime using RAS?

 

Resolution

To pass a parameter value to a subreport at runtime using RAS, use the following code sample:

Public Class WebForm1

Inherits System.Web.UI.Page

Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer

Dim ReportDoc As New CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument()

Dim subparamValues As New CrystalDecisions.ReportAppServer.DataDefModel.Values()

Dim subParamValue As New CrystalDecisions.ReportAppServer.DataDefModel.ParameterFieldDiscreteValue()

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

ReportDoc.Open("C:\rasreports\simplereport.rpt")

subParamValue.Value = 70

subparamValues.Add(subParamValue)

ReportDoc.DataDefController.ParameterFieldController.SetCurrentValues("sub1", "units", subparamValues)

CrystalReportViewer1.ReportSource = ReportDoc

End Sub

End Class

Keywords

SUB REPORT RAS9 DOTNET .NET VS.NET PARAM FILTER Crystal Enterprise Report Application Server Subreports Parameters , c2012429 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008