on 09-01-2008 6:26 AM
Hi,
How to create a Crystal Report for user AddOn.How to load the report through coding when i click a print button.
Regards
Mohana
Hi
See B1 Application menu bar is there Launch Application Click first,Click New button and give application name,path name(ur exe name-report) and run.
Regards..
billa 2007
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mohana,
Just see the following links,
Crystal Reports Integration for SAP Business One
Hope it helps,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then in VS 2005 how are u using CR 2008...??
R u using the embedded version on CR..??
Generally for these kindi of req i add a Crystal report file and a windows forms and using the report viewer control i pass the report to the form.
And on the print button click i show this form with the report.
Vasu Natari.
Edited by: vasu natari on Sep 1, 2008 11:27 AM
Hi Mohana,
Plz check the following code..
Public Sub DisplayReport()
Dim objRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim dstemp, dstemp2 As DataSet
dstemp = dsReportData
dstemp2 = dsReportData
objRep.Load(System.Windows.Forms.Application.StartupPath & "\CrystalReports\rptDocumentProdTypeB.rpt")
Dim frmRepDisp As New frmReportDisplay ' This is the windows form added to my code.
frmRepDisp.WindowState = FormWindowState.Maximized
objRep.SetDataSource(dsReportData) 'I'm passing the data to my report in the form of a data source.
frmRepDisp.CrystalReportViewer1.ReportSource = objRep 'Here i am setting the report for the report viewer control in the Windows form.
frmRepDisp.CrystalReportViewer1.Refresh()
frmRepDisp.ShowDialog()
dsReportData.Clear()
End Sub
In the above case as i have many reports to display i am sending the path of the report file u can do it without that also.
And i call the above prcedure in the Item pressed event after loadng my dataset with data.
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
If pVal.ItemUID = "11" Then
LoadDatatoReport(aForm) 'Fill the data in the data sets.
DisplayReport() 'Display the report.
End If
Hope its Helpful,
Regards,
Vasu Natari.
Edited by: vasu natari on Sep 1, 2008 12:18 PM
Hi Vitor,
Plz check the following code for the method.
Public Sub LoadDatatoReport(ByVal bForm As SAPbouiCOM.Form)
oDtable = bForm.DataSources.DataTables.Item("oDtable")
For intRecCount As Integer = 0 To oDtable.Rows.Count - 1
oDRow = dsReportData.Tables.Item("DataTable1").NewRow()
oDRow.Item("CustName") = oDtable.GetValue("CustName", intRecCount) 'objDelDoc.CardCode
oDRow.Item("ClientOrderNo") = oDtable.GetValue("ClientOrderNo", intRecCount)
oDRow.Item("NumAtCard") = oDtable.GetValue("NumAtCard", intRecCount)
oDRow.Item("DocDueDate") = oDtable.GetValue("DocDueDate", intRecCount)
oDRow.Item("CustomerAddress") = oDtable.GetValue("CustomerAddress", intRecCount)
oDRow.Item("ClientSalesPerson") = oDtable.GetValue("ClientSalesPerson", intRecCount)
oDRow.Item("CustContactPerson") = oDtable.GetValue("CustContactPerson", intRecCount)
oDRow.Item("U_Installation") = oDtable.GetValue("U_Installation", intRecCount)
oDRow.Item("ClientItemNo") = oDtable.GetValue("ClientItemNo", intRecCount)
oDRow.Item("ItemDesc") = oDtable.GetValue("ItemDesc", intRecCount)
oDRow.Item("GAno") = oDtable.GetValue("GAno", intRecCount)
oDRow.Item("MaterialQualityNo") = oDtable.GetValue("MaterialQualityNo", intRecCount)
'MsgBox(oDtable.GetValue("BatchNo", intRecCount))
oDRow.Item("BatchNo") = oDtable.GetValue("BatchNo", intRecCount)
oDRow.Item("LineNo") = oDtable.GetValue("LineNo", intRecCount)
oDRow.Item("U_ProdNo") = oDtable.GetValue("U_ProdNo", intRecCount)
oDRow.Item("Equipment") = oDtable.GetValue("Equipment", intRecCount)
oDRow.Item("BondraGrpNo") = oDtable.GetValue("BondraGrpNo", intRecCount)
oDRow.Item("ItemSpecialNo") = oDtable.GetValue("ItemSpecialNo", intRecCount)
dsReportData.Tables.Item("DataTable1").Rows.Add(oDRow)
Next
End Sub
I'll be having a data set or an XSD file associated with my Crystal report and i'll be filling that data set and passing to the report.
For the general info abt crystals u can try google.
Hope it helps.
Regards,
Vasu Natari.
Vasu,
I've got my reporting system up and running, but I'm not using DataSets or XSD files.
I created a Windows form with a CrystalReportViewer control, and in run time I just have to set the report filename, the title and formulas (if any).
My question is, do you think I'll stomp into any limitation with this approach?
I'm using the following code:
Public Class ADAT_Crystal
Private DBUserid As String = "sa"
Private DBPassword As String = "XXYYZZ"
Private rptPath As String = ""
Private rptConnectionInfo As ConnectionInfo
Private rptDocument As ReportDocument
Private rptCrystalForm As CrystalForm
Private SelectionString As String = ""
Public Function LoadCrystal(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, _
ByRef Titulo As String, ByRef ReportName As String, ByRef Parametros As String, ByRef Formulas As String) As Boolean
LoadCrystal = False
Try
rptPath = sPath & "reports" & ReportName
SelectionString = Formulas
SetDBConnection(oApplication, oCompany)
SetReportDocument(oApplication)
SetDBLogonForReport(oApplication)
SetCrystalForm(oApplication, Titulo)
LoadCrystal = True
Catch ex As Exception
End Try
End Function
Private Sub SetDBConnection(ByRef oApplication As SAPbouiCOM.Application, ByRef oCompany As SAPbobsCOM.Company)
Try
rptConnectionInfo = New ConnectionInfo()
rptConnectionInfo.DatabaseName = oCompany.CompanyDB
rptConnectionInfo.UserID = DBUserid ' GetDBUserdID()
rptConnectionInfo.Password = DBPassword ' GetDBUserPassword()
rptConnectionInfo.ServerName = oCompany.Server
Catch ex As Exception
oApplication.StatusBar.SetText(TranslateStr(oApplication, Error_) & ex.Message)
End Try
End Sub
Private Sub SetReportDocument(ByRef oApplication As SAPbouiCOM.Application)
Try
rptDocument = New ReportDocument
rptDocument.Load(rptPath)
rptDocument.DataDefinition.RecordSelectionFormula = SelectionString
Catch ex As Exception
oApplication.StatusBar.SetText(TranslateStr(oApplication, Error_) & ex.Message)
End Try
End Sub
Private Sub SetDBLogonForReport(ByRef oApplication As SAPbouiCOM.Application)
Try
Dim myTables As Tables = rptDocument.Database.Tables
For Each myTable As Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = rptConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
Catch ex As Exception
oApplication.StatusBar.SetText(TranslateStr(oApplication, Error_) & ex.Message)
End Try
End Sub
Private Sub SetCrystalForm(ByRef oApplication As SAPbouiCOM.Application, ByRef Titulo As String)
Try
rptCrystalForm = New CrystalForm()
rptCrystalForm.Text = Titulo
rptCrystalForm.oCrystalReportViewer.ReportSource = rptDocument
rptCrystalForm.oCrystalReportViewer.Refresh()
rptCrystalForm.ShowDialog()
Catch ex As Exception
oApplication.StatusBar.SetText(TranslateStr(oApplication, Error_) & ex.Message)
End Try
End Sub
Handling the PrintPreview click
Case "519"
Dim SelectionString As String = "{ONP.DocNum} = " & Trim(oForm.Items.Item("DocNum").Specific.Value) & ""
Dim oCrystal As New ADAT_Crystal
oCrystal.LoadCrystal(oCompany, oApplication, "Nota de Produção", "rptNotaProd.rpt", "", SelectionString)
Return False
Regards,
Vítor Vieira
Hi Vitor,
If u have opened a new thread i could have got some points but anyways.... i'll share..
The problem with the above approach is that we need to have the Physical .RPT file at the system in the default folder. So if we miss the file we get a file not found error.
Hope its helpful.
Vasu Natari.
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.