cancel
Showing results for 
Search instead for 
Did you mean: 

CR View on SAP B1 Form

Former Member
0 Kudos

Hello,

Can somebody discovered already that what is the ActiveX ID of Crystal Report Viewer ActiveX control. I would like to display a CR report in my B1 Form. Please post your experiences for me with assigning a report from a file to the viewer.

Regards

János

Accepted Solutions (1)

Accepted Solutions (1)

marco_laporta
Participant
0 Kudos

I successfully loaded a CR Report Viewer in a B1 Form, through code, in the following way:

1) I used OLEDB connection instead of SAB B1 Connection. I didnu2019t find a way to change by code a SAP B1 Connection!!!

2) Because I get ever an Error changing the connection of the ActiveX CrystalReports12.ActiveXReportViewer.1 (from a SAP B1 Form), I write a NET UserControl and expose it for COM Interop. The UserControl contains a NET CR Report Viewer.

When writing the UserControl, remember:

-) Write a UserControl for COM interop.

-) Sign the assembly and install in a global assembly cache

-) Add the code for channel like showed in this thread [], or you will get a strange error about channels.

-) Use BeginInvoke (and InvokeRequired) for invoking methods in UserControl, because methods and constructor are called in different threads

3) In a B1 form use an ActiveX item with classid="MyNameSpace.MyUserControlClass"

I didnu2019t understand the reason for which I cannot use the ActiveX CrystalReports12.ActiveXReportViewer.1, but the same working code changing an OLEDB connection will raise a System.InvalidCastException if executed on the ActiveXReportViewer.

Also, I didnu2019t understand why I cannot change a SAB B1 Connection, but really I tried almost every possible property combination and I havenu2019t success.

Iu2019m still not sure about the name of property u201CCompany User Passwordu201D because I didnu2019t found any documentation about SAB B1 Connection.

Hope this help

Regards

Marco

Former Member
0 Kudos

Dear Marco,

Did you find possibility to avoid 'Logon Failed' issue, when report has SAP B1 connectivity type?

I don't use ActiveX controls, i just want to execute report and export results to PDF or print to printer.

everything works fine, when datasource type is OLE DB, but when datasource type is SAP B1, it does not work and throws exception - Logon Failed.

my original topic:

i'll appreciate for any suggestions

marco_laporta
Participant
0 Kudos

Konstantin , sorry but I din't have success in using SAP B1 connectivity type, and I tried almost everithing.

I continue using OLE DB or XML DataSet

Regards

Marco

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Janos,

     It seems to old for this thread. Can you please share your code on how did you view your CR in SAP b1 form.

Regards,

marco_laporta
Participant
0 Kudos

I have done some step but it stil not work.

If i substitute

 
          foreach (Table table in rcd.Database.Tables) {
                rcd.DatabaseController.ModifyTableConnectionInfo(table.Alias, newConnectionInfo);
            }

with

 
          rcd.DatabaseController.ReplaceConnection(
                currentConnectionInfo, newConnectionInfo, null,
                CrDBOptionsEnum.crDBOptionDoNotVerifyDB | CrDBOptionsEnum.crDBOptionUseDefault);

the report detect the data connectivity changes, but still prompt me for server/password.

Janos, did you have sucess?

Marco

marco_laporta
Participant
0 Kudos

Janos,

Sorry, I did not explain very well.

I would like to open a CR report in SAP B1, in a B1 form, like you.

To achieve this I need to change database connectivity by code.

I read that to change report by code, in Crystal report 2008 you must use RAS SDK that works as a RAS server in-process (not really a server).

So I divide the problem in 2 step:

Step 1)

I try to have a normal NET form with a CrystalReportViewer in which I can change database connectivity.

Step 2)

I will try to put code realized in step 1) in a B1 form with the ActiveX CrystalReports12.ActiveXReportViewer.1

The ActiveX should be the COM wrapper of the CrystalReportViewer NET components, so I think that if I have success in step 1) also step 2) should work.

I use B1 8.8 and I donu2019t need CR Addon to user CR in B1.

For me is very important that I can setup a u201CSAP Business Oneu201D Connection type because I realized that is fastest than an ADO connection.

This connection type was provided by crdb_b1.dll (like you said) but I cannot setup a working connection by code (see my code).

The problem was that I havenu2019t success in Step 1!

Best Regards

Marco

marco_laporta
Participant
0 Kudos

Janos,

Before trying ActiveX, I tried to view a report connected to B1 in a normal NET window (with CrystalReportViewer)

So:

1) I write a report connected through "SAP Business One" Connection type

2) I use the code in the following (that does'nt work)

CR prompts me for logon but it does not logon also if I use right credential.

In particular it seems that my code does'nt change anything in the data connectivity because CR prompts me the older server name.

I also tried to put a not existing dll name in 'Database DLL' property, and I have no errors, but I cannot logon.

I take the properties for the connectionInfo from an existing connection. I'm not sure about Company User Password because obviously it wasn't saved in the report.

Someone solved the problem?

Thanks in Advance

Marco



public void OpenReport(string Path) {


            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
           

            rd.Load(Path);

            //Cancel Data
            rd.Refresh();


           ISCDReportClientDocument rcd = rd.ReportClientDocument;


            ConnectionInfo newConnectionInfo = new ConnectionInfoClass();
            //ConnectionInfo currentConnectionInfo = new ConnectionInfoClass();
            PropertyBag logonAttributes = new PropertyBagClass();
            PropertyBag connectionAttributes = new PropertyBagClass();

            logonAttributes.Add("Server", "COTTONMOUTH\\MSSQLSERVER8");
            logonAttributes.Add("Server Type", "MSSQL2008");
            logonAttributes.Add("B1 License Server", "COTTONMOUTH:30000");
            logonAttributes.Add("Company User Id", "manager");
            logonAttributes.Add("Company User Password", "pass");
            logonAttributes.Add("Database", "SBODemoIT");
            logonAttributes.Add("Security", false);
           


            connectionAttributes.Add("Database DLL", "crdb_b1.dll"); 
            connectionAttributes.Add("QE_DatabaseName", "SBODemoIT");
            connectionAttributes.Add("QE_DatabaseType", "SAP Business One");
            connectionAttributes.Add("QE_LogonProperties", logonAttributes);
            connectionAttributes.Add("QE_ServerDescription", "COTTONMOUTH\\MSSQLSERVER8");
            connectionAttributes.Add("QE_SQLDB", true);
            connectionAttributes.Add("SSO Enabled", false);

            newConnectionInfo.Attributes = connectionAttributes;
            newConnectionInfo.UserName = "sa";
            newConnectionInfo.Password = "pass";
            newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;

           
            foreach (Table table in rcd.Database.Tables) {
                rcd.DatabaseController.ModifyTableConnectionInfo(table.Alias, newConnectionInfo);
            }

          

            try {
                rd.VerifyDatabase();
                MessageBox.Show("OK");
            }
            catch (Exception ex) {
                logger.Error("Error",ex);
            }
            

            crystalReportViewer1.ReportSource = rd;
            
        }

Former Member
0 Kudos

Dear Marco,

Thanks, but i would like to display some kind of report and several other elements in SAP B1 form like Xcelsius Dashboards, etc. You have wtitten a question which is not related to this topic in this thread.

Solution is easy for your problem: Create a table (any) where you store the password of the database user or create a user in the database (CRVIEW as in the old versions) with read-only rights, and run the report under the name. You must provide any password in the report you have created otherwise not working (if you have used CR addon, you there also provindin a password after installation).

regards

János

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Janos,

The Crystal report ClassID depends on the Crystal Reports version you are working with.

Here you have the ClassID for the version 11.5:

You need to use the CrystalActiveXReportViewerLib in order to get the viewer and call the ViewReport method:

Public myCrystalReportViewer As CrystalActiveXReportViewerLib11_5.CrystalActiveXReportViewer

myCrystalReportViewer.ViewReport()

And you need to give the corresponding ClassID to build the B1 UI API ActiveX item:

oActiveX.ClassID = "CrystalReports115.ActiveXReportViewer.1"

Which version are you working with?

Regards

Trinidad.

Former Member
0 Kudos

Hello Trinidad,

Many thanks for your answer. I was searching the forum after posted by Question but did not find this thread you have posted.

So I have 10.2 version installed. and it is not working as i wanted. B1 dumps

I will upgrade CR runtime files to 11.5 or 12 (I have BOE 3.1 = BO12) installed, i will check also the viewer there.

To go forward in this topic i have figured out some stuffs. These steps maybe logical, and i have followed the Crystal Reports Addon distributed on SDN. This is opens a different (Windows forms based) window where the print layout is shown.

Environment: B1 - 8.8 PL 10

My steps If I feel correct:

1. Creating activex viewer - let's say done

2. I need some object which holds the report itself, and can be customized by parameters of the report.

3. As next step, i shoudl define connection to SAP B1 database.

4. I need to display the report

I tried these steps with 10.2 version of ActiveX viewer, but (VB.NET CODE version 2005)

oItem = oForm.Items.Add("4", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)
'Step 1Creating activex viewer 
oItem.Top = 5
oItem.Left = 5
oItem.Width = Maxw
oItem.Height = Maxh

Dim oActiveX1 As SAPbouiCOM.ActiveX = oItem.Specific
Dim CRViewer As CrystalActiveXReportViewerLib102.CrystalActiveXReportViewer
'Here we can use VersionIndependentProgID property from registry, which is better the defining the version based on my Experience , but i have used the version dependent.
CRViewer = oActiveX1.Object

'step 2. I need some object which holds the report itself, and can be customized by parameters of the report.
Dim CRApp As New CRAXDDRT.Application
Dim CRRep As New CRAXDDRT.Report

'step 3.  i shoudl define connection to SAP B1 database
CRApp.LogOnServer( DLLNAME, "SERVERNAME", "COMPANYDB", "DBUSER", "DBPWD")
CRRep = CRApp.OpenReport(System.Windows.Forms.Application.StartupPath() + "sample.rpt")

'step 4 display the report
CRViewer.ReportSource = CRRep
CRViewer.ViewReport()

where

CRAXDDRT - is the Crystal Report ActiveX Designer and Runtime Library 10.2 version.

the problem is at step 3 - (maybe).

Which DLL should be provided to connect to SAP B1 database. I have found in the C:Program FilesSAPSAP Business OneCrystalcrdb_b1.dll which maybe the B1 connector build by the development team.

What do you think?

Regards

János

Edited by: János Nagy on Jun 8, 2010 1:26 PM