8

Crystal Reports ODBC Connection to SAP HANA DB

 2 years ago
source link: https://answers.sap.com/questions/12740556/crystal-reports-odbc-connection-to-sap-hana-db.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Crystal Reports ODBC Connection to SAP HANA DB

Search Questions and Answers
Jul 24, 2019 at 04:04 PM

Crystal Reports ODBC Connection to SAP HANA DB

6772 Views Last edit Aug 12, 2019 at 05:35 PM 2 rev


i have a problem. When i change the ODBC connection string runtime (Programmatically) i have a problem when the program are in execution using x64 processor architecture. Every time when i going to print or export the report i have a connection error but when the program are in execution using x32 processor architecture the problem can't persist.

My connection string is:

DRIVER=B1CRHPROXY32;SERVERNODE=ServerName:30015;DATABASE=DataBaseName;

The error: "Error to open the report connection".



I use .net SDK whit sap crystal report 2016 and the crystal report integration for sap business one version 9.3 PL 09.

I'm sure that there are a solution.

Thank you and best regards Tommaso.



5 Answers
Sort by:
Jul 26, 2019 at 10:39 PM

So I have a c# program that I use the SDK to generate Crystal Reports invoices for

This is just an example of what I do.

This uses a standard SAP B1 Crystal Invoice, passing the Object ID and DocEntry values

Saves a copy of the invoice to a local server/computer

public static void CreateInvoicePDF(int DocEntry, string CardCode, string CustomerName, string InvoiceNo, decimal InvoiceAmount, string WebOrderNo, bool Paid, string CustomerEmail, string ReportPath, string Key)
        {
            bool FileFound = false;
            string InvoicePath;
            string InvoiceFileName = string.Empty;

            string SAP_Server = ConfigurationManager.AppSettings["SAP_Server"];
            string SAP_DBUID = EncryptProvider.AESDecrypt(ConfigurationManager.AppSettings["SAP_DBUID"], Key);
            string SAP_DBPass = EncryptProvider.AESDecrypt(ConfigurationManager.AppSettings["SAP_DBPass"], Key);
            string SAP_DBName = ConfigurationManager.AppSettings["SAP_CompanyDB"];

            InvoiceFileName = string.Format("Invoice_{0}", InvoiceNo) + ".pdf";

            ReportDocument CRRpt = new ReportDocument();
            InvoicePath = string.Concat(ReportPath,"\\PDF-Invoices\\", InvoiceFileName);

            // Get the Crystal report
            CRRpt.Load(ReportPath + "\\D4W-Invoice-2.rpt");

            string strConnection = string.Format("DRIVER={0};UID={1};PWD={2};SERVERNODE={3};DATABASE={4};", "{B1CRHPROXY32}", SAP_DBUID, SAP_DBPass, SAP_Server, SAP_DBName);


            NameValuePairs2 logonProps2 = CRRpt.DataSourceConnections[0].LogonProperties;
            logonProps2.Set("Provider", "B1CRHPROXY32");
            logonProps2.Set("Server Type", "B1CRHPROXY32");
            logonProps2.Set("Connection String", strConnection);
            //logonProps2.Set("Locale Identifier", "1033");


            CRRpt.DataSourceConnections[0].SetLogonProperties(logonProps2);
            CRRpt.DataSourceConnections[0].SetConnection(SAP_Server, SAP_DBName, false);
            CRRpt.SetParameterValue("DocKey@", DocEntry);
            CRRpt.SetParameterValue("ObjectId@", int.Parse("13"));

            // Export the report
            CRRpt.ExportToDisk(ExportFormatType.PortableDocFormat, InvoicePath);

            CRRpt.Close();
            CRRpt.Dispose();

        }
}
2 comments
6 minutes ago

Thanks , that helped a lot.

In case anyone pass by.

Just we faced a connection error while the connection string is OK but the below fixed the issue >>

string strConnection = string.Format("DRIVER={0};UID={1};PWD={2};SERVERNODE={3};DATABASE={4};", "{B1CRHPROXY32}", SAP_DBUID, SAP_DBPass, SAP_Server, SAP_DBName);

NameValuePairs2 logonProps2 = CRRpt.DataSourceConnections[0].LogonProperties;

logonProps2.Set("Provider", "{B1CRHPROXY32}");

logonProps2.Set("Server Type", "{B1CRHPROXY32}");

logonProps2.Set("Connection String", strConnection);

CRRpt.DataSourceConnections.Clear();

CRRpt.DataSourceConnections[0].SetLogonProperties(logonProps2);

CRRpt.DataSourceConnections[0].SetConnection(SAP_Server, SAP_DBName, false);

CRRpt.Refresh();

CRRpt.SetParameterValue("DocKey@", 2161);

CRRpt.SetParameterValue("ObjectId@", int.Parse("13"));


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK