cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Preview of Crystal Report

Former Member
0 Kudos

Hello Experts !!!!!

I have created a User Defined Form through SDK. I have created a Crystal Report also for that Form. Now on the click of Preview Menu of SBO I want to open my Crystal report. For this I have called the following function in Menu Event.....

   

Private Function LoadCrViewer(ByVal crxReport As CRAXDDRT.Report) As Boolean

        Dim SBOFormCreationParams As SAPbouiCOM.FormCreationParams
        Dim SBOCRViewer As SAPbouiCOM.ActiveX
        Dim SBOForm As SAPbouiCOM.Form
        Dim SBOItem As SAPbouiCOM.Item

        Dim strFormCount As String

        SBOFormCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
        SBOFormCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable
        SBOFormCreationParams.FormType = "XX_INCRPT01"
        strFormCount = SBO_Application.Forms.Count.ToString
        SBOFormCreationParams.UniqueID = "XX_INCRPT01" & strFormCount.PadLeft(3, "0")

        'Add new form
        SBOForm = SBO_Application.Forms.AddEx(SBOFormCreationParams)
        SBOForm.Left = 0
        SBOForm.Top = 0
        SBOForm.Width = SBO_Application.Desktop.Width
        SBOForm.Height = SBO_Application.Desktop.Height
        SBOForm.Title = "inCentea - Mapas"

        'Add CRViewer item
        SBOItem = SBOForm.Items.Add("XX_CR01", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)
        SBOItem.Left = 0
        SBOItem.Top = 0
        SBOItem.Width = SBOForm.ClientWidth
        SBOItem.Height = SBOForm.ClientHeight

        ' Create the new activeX control
        SBOCRViewer = SBOItem.Specific

        SBOCRViewer.ClassID = "CrystalReports13.ActiveXReportViewer.1"

        Dim SBOCRViewerOBJ
        SBOCRViewerOBJ = SBOCRViewer.Object
        SBOCRViewerOBJ.EnablePrintButton = False

        Dim MyProcs() As Process
        Dim i, ID As Integer
        Dim a As System.IntPtr

        'Try Send the handle of SAP window
        SBO_Application.Desktop.Title = "SBO under " + SBO_Application.Company.UserName
        MyProcs = Process.GetProcessesByName("SAP Business One")
        For i = 0 To MyProcs.Length - 1
            If MyProcs(i).MainWindowTitle = SBO_Application.Desktop.Title Then
                ID = MyProcs(i).Id()
                a = MyProcs(i).MainWindowHandle
                crxReport.SetDialogParentWindow(a.ToInt32)
                'crxReport.PrinterSetup(a.ToInt32)
                'crxReport.PrintOut(False)
            End If
        Next

        SBOCRViewerOBJ.ViewReport()

        SBOForm.Visible = True

        Return True

    End Function


But this Code is throwing an exception "No report to view." on the statement "SBOCRViewerOBJ.ViewReport()"

Please let me know where is the problem? And if possible then please rectify the Code.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hello,

I have same issue as yours,

If you have found the solution for the same, please post the solution here, so that we can refer to it.

Thanks in advance for your help.