cancel
Showing results for 
Search instead for 
Did you mean: 

sap business one sdk

Former Member
0 Kudos

in sap business one sdk how DI API is connect.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

threre r two method for connection

1. single sign one connection

2 seprate connection

In the single sign one connection we connect to UI api nd DI api ,

In the seprate connection we r connect seprate DI api nd UI api ,

This is single sign one code. connect to di api

private SAPbobsCOM.Company oCompany;

private void SetApplication() {

// *******************************************************************

// // Use an SboGuiApi object to establish connection

// // with the SAP Business One application and return an

// // initialized appliction object

// *******************************************************************

SAPbouiCOM.SboGuiApi SboGuiApi = null;

string sConnectionString = null;

SboGuiApi = new SAPbouiCOM.SboGuiApi();

// // by following the steps specified above, the following

// // statment should be suficient for either development or run mode

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

// // connect to a running SBO Application

SboGuiApi.Connect( sConnectionString );

// // get an initialized application object

SBO_Application = SboGuiApi.GetApplication( -1 );

}

private int SetConnectionContext() {

int setConnectionContextReturn = 0;

string sCookie = null;

string sConnectionContext = null;

int lRetCode = 0;

// // First initialize the Company object

oCompany = new SAPbobsCOM.Company();

// // Acquire the connection context cookie from the DI API.

sCookie = oCompany.GetContextCookie();

// // Retrieve the connection context string from the UI API using the

// // acquired cookie.

sConnectionContext = SBO_Application.Company.GetConnectionContext( sCookie );

// // before setting the SBO Login Context make sure the company is not

// // connected

if ( oCompany.Connected == true ) {

oCompany.Disconnect();

}

// // Set the connection context information to the DI API.

setConnectionContextReturn = oCompany.SetSboLoginContext( sConnectionContext );

return setConnectionContextReturn;

}

private int ConnectToCompany() {

int connectToCompanyReturn = 0;

// // Establish the connection to the company database.

connectToCompanyReturn = oCompany.Connect();

return connectToCompanyReturn;

}

.................this is code for cneect ui api nd di api..............

...........................................////////........................................this is code for connect for di api seprate.....................................................

Dim oCompany As SAPBobsCOM.Company

Dim lRetCode, lErrCode As Long

Dim sErrMsg as String

'Instanciate a Company object

oCompany = New SAPBobsCOM.Company

oCompany.Server = "(local)"

oCompany.CompanyDB = "SBODemo_US"

oCompany.UserName = "manager"

oCompany.Password = "manager"

oCompany.Language = ln_English

‘Sample: Use Windows Auth. to SQL Server

oCompany.UseTrusted = True

‘Set AddOn identifier (new in 2004)

oCompany.AddOnIdentifier = “Your Add-On Identifier”

lRetCode = oCompany.connect

'Check Return Code

If lRetCode <> 0 Then

oCompany.GetLastError lErrCode, sErrMsg

End If

.applay any one code for coonection tp di api....

if u have any problem replay me ,

nd if u r satisfied than give me rewards point.

Answers (1)

Answers (1)

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

Venkat,

I am not 100% sure of what you are asking. Are you asking how to connect to the DI API using code? Can you give more detail on what you are looking for?

The DI API connection through code you may create is listed in detail in the SAP Business One SDK Help Center Documentation that comes with the SAP Business One SDK as well as the DI API sample code that comes with the SDK.

Eddy