cancel
Showing results for 
Search instead for 
Did you mean: 

Error Connecting DIAPI

Former Member
0 Kudos

Hello.

I have a problem connecting to an AddOn DIAPI, this is the portion of code.

SAPbobsCOM.Company oCompañiaSBO;

SAPbouiCOM.Application oAplicacionSBO;

try

{

     oCompañiaSBO = new SAPbobsCOM.Company();

     oCompañiaSBO = (SAPbobsCOM.Company)oAplicacionSBO.Company.GetDICompany();

     return true;

}

catch (Exception oError)

{

       return false;

}

The mistake me throws me off the marked line is the following:

System.Runtime.InteropServices.COMException (0xFFFFFF7D):

There was an internal error (-131) [131-183] - in SAPbouiCOM.ICompany.GetDICompany ()

I have read in some other post that the problem may be in the b1-Local machine.xml-file found

in C: \ Program Files (x86) \ SAP \ SAP Business One DI API \ Conf, you must change the line where indicated

the server, by default has the value and need LocalHost change the name or IP address of the server

I did this already and does not work, we should mention that this problem only occurs in the SAP Client on the server as

the AddOn works properly.

Has anyone had this problem? I would greatly appreciate guidance. Greetings.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Verify that the oAplicacionSBO object is already initialized and connected before calling the .. Company.GetDICompany().

Beni.

Former Member
0 Kudos

Hi Beni

This problem only occurs in the machine where I'm developing.

In other machines and even the SAP server code I posted does not have any problem.

Now, when I do a debug code if the object is initialized and has some values ​​like DB user and other data.

Currently the way I'm replacing that method is with the following code:

try

            {

                this.oCompañiaSBO = new SAPbobsCOM.Company();

                this.oCompañiaSBO.Server = "sap33";

                this.oCompañiaSBO.UseTrusted = false;

                this.oCompañiaSBO.LicenseServer = "sap33:30000";

                this.oCompañiaSBO.DbServerType = BoDataServerTypes.dst_MSSQL2008;

                this.oCompañiaSBO.DbUserName = "manager";

                this.oCompañiaSBO.DbPassword = "password";

                this.oCompañiaSBO.CompanyDB = "INFINITY";

                this.oCompañiaSBO.UserName = "manager";

                this.oCompañiaSBO.Password = "password";

                int i = this.oCompañiaSBO.Connect();

                return true;

            }

            catch (Exception oError)

            {

                return false;

            }

edy_simon
Active Contributor
0 Kudos

Hi Raul,

First, try to remove the SM_OBS_DLL folder in temp folder.

If that does not solve your problem,

Can you try first connecting with

            oCompañiaSBO = new SAPbobsCOM.Company();

            string cookie = oCompañiaSBO.GetContextCookie();

            string connInfo = oAplicacionSBO.Company.GetConnectionContext(cookie);

            retCode = oCompañiaSBO.SetSboLoginContext(connInfo);

            if (retCode != 0)

            {

              // ERROR!

              return oCompañiaSBO.GetLastErrorDescription();

            }

Usually this method will give you a more specific error message.

Once you have corrected the problem, you can then switch to your original code.

Regards

Edy

Former Member
0 Kudos

Hi Edy.

I commented.

I delete the folderon in my system there are two, one in

C 😕 Windows / Tem

and one in the user temp folder, delete both still not working yet.

Regarding the code you provided it does not throw me any errors.

Now I commented that sent me the following error when trying to connect.

{System.Runtime.InteropServices.COMException (0xFFFFFF7D): There was an internal error (-131) [131-183] -

    in SAPbouiCOM.ICompany.GetDICompany ()

Greetings and thanks.

edy_simon
Active Contributor
0 Kudos

Hi Raul,

I forgot one block in the code above.

            retCode = oCompañiaSBO.SetSboLoginContext(connInfo);

            if (retCode != 0)

            {

              // ERROR!

              return oCompañiaSBO.GetLastErrorDescription();

            }

           else

            {

               oCompañiaSBO.Connect();

               if (!oCompañiaSBO.Connected)

                    return oCompañiaSBO.GetLastErrorDescription();

            }


Regards

Edy


Former Member
0 Kudos

Hi Edy

Now try this code and falls into the else case throws an error and I wrote you up.