Skip to Content
avatar image
Former Member

UI/DI API connection to SAP HANA

Hello everybody,

I try to set up a UI/DI API connecting from local SAP HANA Client to remote SAP HANA Server. UI connection is successful and SBO_Application object is created with success from code below:

sConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();

SboGuiApi.Connect(sConnectionString);

SBO_Application = SboGuiApi.GetApplication();

I even get

ret_Url = SBO_Application.XSEngineBaseURL;

with success.

Though when I try to get DI company object:

oCompany = new SAPbobsCOM.Company();
oCompany = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany();

I get an exception "Invalid Memory Access"

Alternatively I tried to connect with code below and got connection error from sap with code -119 and message "Database server type not supported"

The code is:

public void setApplication()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sConnectionString = null;
            SboGuiApi = new SAPbouiCOM.SboGuiApi();
            sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
            SboGuiApi.Connect(sConnectionString);
            SBO_Application = SboGuiApi.GetApplication(-1);
        }


        public int SetConnectionContext()
        {
            int setConnectionContextReturn = 0;
            string sCookie = null;
            string sConnectionContext = null;
            oCompany = new SAPbobsCOM.Company();
            sCookie = oCompany.GetContextCookie();
            sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie);
            if (oCompany.Connected == true)
            {


                oCompany.Disconnect();


            }
            setConnectionContextReturn = oCompany.SetSboLoginContext(sConnectionContext);
            return setConnectionContextReturn;
        }


        public int ConnectToCompany()
        {


            int connectToCompanyReturn = 0;
            connectToCompanyReturn = oCompany.Connect();
            var error = oCompany.GetLastErrorDescription();
            return connectToCompanyReturn;
        }

Finally, I used HanaConnection object from Sap.Data.Hana.v4.5.dll and everything worked alright, managed to retrieve data from SAP HANA Database.

Any suggestions on helping me to solve this problem are much appreciated.

Kind Regards,

Dimitris

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Feb 10, 2017 at 09:50 AM

    Hi Dmitris,

    Have you tried re-installing the DI API?

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Pedro,

      that did the trick. Once again thank you very much for your quick and accurate response.

      Kind Regards,

      Dimitris