Showing results for 
Search instead for 
Did you mean: 

Open CR viewer from custom addon

0 Kudos

Hey guys, how I can open crystal report from local folder (local directory of my addon for SAP b1\Reports\report.rpt) and show it inside of SAP B1 as a other reports? Can someone share some code how to open reports from custom addon form?


View Entire Topic
0 Kudos

According to code you wroute you want to add Document as control to windows form, but this is not allowed anyway.I want to open it in CrystalReportViewer as you opening all reports in SAP when you click on PDF icon in top menu. But this is when you have report assigned in Report and Layout manager. But I did not figure how to add report to my own addon form. For now I have this part of code and missing this showing functionality, as adding ActiveX control (CR report viewer) to form is not working and there I am stuck. Also I am adding data to report throw ODBC, than what I need just to do, its open report in viewer or as PDF file as data are already in report....

                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(@"C:\Program Files\SAP\SAP Business One\AddOns\2J_General\Reports\JJ_KosikovyList_balenie.rpt");
rptDoc.SetParameterValue("@ShipDate", DateTime.Now); //FromDatePicker.SelectedDate
SAPbouiCOM.FormCreationParams SBOFormCreationParams = (SAPbouiCOM.FormCreationParams) Application.SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams);
SBOFormCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable;
SBOFormCreationParams.FormType = "XX_INCRPT01";
String strFormCount = Application.SBO_Application.Forms.Count.ToString();
SBOFormCreationParams.UniqueID = "XX_INCRPT01" & strFormCount.PadLeft(3,"0"); //also hawing problem here, but its not critical one
//Add new form
SAPbouiCOM.Form SBOForm = Application.SBO_Application.Forms.AddEx(SBOFormCreationParams);
SBOForm.Left = 0;
SBOForm.Top = 0;
SBOForm.Width = 500;// Application.SBO_Application.Desktop.Width;
SBOForm.Height = 600;// Application.SBO_Application.Desktop.Height;
SBOForm.Title = "ZO";

//after this point I am adding ActiveX componenent to form (it need be form in SAP not Windows form, but if you have solution for WinForm as well than I would like to see it) to show report but its not working:
SAPbouiCOM.Item SBOItem = SBOForm.Items.Add("XX_CR01", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X);
SBOItem.Left = 0;
SBOItem.Top = 0;
SBOItem.Width = 500;// SBOForm.ClientWidth;
SBOItem.Height = 600;// SBOForm.ClientHeight;
SAPbouiCOM.ActiveX oActX = (SAPbouiCOM.ActiveX)SBOItem.Specific;
oActX.ClassID = "{645FE3FB-6922-4EF3-9E21-5A1176CA12BA}";// "CrystalReports13.ActiveXReportViewer.1"; //or use the GUID "{645FE3FB-6922-4EF3-9E21-5A1176CA12BA}"
CrystalActiveXReportViewerLib13.CrystalActiveXReportViewer SBOCRViewer = (CrystalActiveXReportViewerLib13.CrystalActiveXReportViewer) oActX.Object ; //In this point its always failing to continue
SBOCRViewer.ReportSource = rptDoc;
0 Kudos


I think I'm having the same problem.

oActX.ClassID = "CrystalReports13.ActiveXReportViewer.1";
CrystalActiveXReportViewerLib13.CrystalActiveXReportViewer SBOCRViewer = (CrystalActiveXReportViewerLib13.CrystalActiveXReportViewer)oActX.Object;

SBOCRViewer.ReportSource = reportDocument;

On line 5 it gives the exception error.


Did you manage to solve it?