cancel
Showing results for 
Search instead for 
Did you mean: 

How to create User Table

Former Member
0 Kudos

I`m trying create User Table from sample COM DI, but when I run code:

Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
 oUserTablesMD = oCompany.GetBusinessObject (SAPbobsCOM.BoObjectTypes.oUserTables)

I receive error on the seccond line:

Object reference not set to an instance of an object.

Any idea how to solve it? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

please check your company object. i think that is not instantiated.

place the following code before Second line

if oCompany= nothing then

MsgBox("not Connected to Company")

End if

oUserTablesMD = oCompany.GetBusinessObject (SAPbobsCOM.BoObjectTypes.oUserTables)

if you get the message means your company object is not instantiated.

Regrads

Vishnu

Former Member
0 Kudos

Vishynu,

you are true, the object isn`t instantiated. It is no problem to make connection as

		oCompany.CompanyDB = 
		oCompany.UserName = 
        oCompany.Password = 
		lRetCode = oCompany.Connect

but is there some possibility to connect through DI without specification of db, name and pswd - the same way as in UI - connect to running instance of SAP?

Former Member
0 Kudos

Hi Petr,

You can connect to the running instance of SAP using the credentials for the UI as you would normally and then just use the DI connection. You can find an example of this (called Single Sign On) in this example:

C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI DI\VB.NET\HelloWorld\2003

Hope it helps,

Adele

Former Member
0 Kudos

Hi

please try with this code

Dim objCompany As SAPbobsCOM.Company

Dim strCookie As String

Dim strCookieContext As String

objCompany = New SAPbobsCOM.Company

strCookie = objCompany.GetContextCookie

strCookieContext = SBOApplication.Company.GetConnectionContext(strCookie)

objCompany.SetSboLoginContext(strCookieContext)

If objCompany.Connect <> 0 Then

strLastError = "Connection Error"

SBOApplication.StatusBar.SetText("Connection Error", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)

Return Nothing

End it

Hope this helps you

Regards

Vishnu

Answers (0)