cancel
Showing results for 
Search instead for 
Did you mean: 

ASP.Net and SAPbobsCOM newby

Former Member
0 Kudos

Hi

can some one help me with

asp.net and SAPbobsCOM.

I need a example to conect to sap

benito

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I built a small webapplication with C# last year (2004A)for internal testing. We used DI-Server as well as DI API to write data into the SAP DB.

This year I had the task to develop a similar web-application but the connection to DI Server as well as to DI-Api faild every time with COM errormessages.

I guess the reason lies somewhere in changes made by SAP in 2005A which are contradictious to the threading modell of C#.

My solution was to write a tiny dll in VB to connect to the DI-API with the connection parameters as input and the company object as output. Doing so you can garantee that retrieving the Company object from SAP B1 use the simple theadmodell of VB instead the multithreaded of C#.

Afterwards everything was fine.

I hope this hints will do.

Regards

Gerd

Former Member
0 Kudos

Is it posible you can send me

the code of then dll that you have created

Former Member
0 Kudos

Here is the whole code. I call the getCompany() method from my C# application and then I use the company object to get for Ex. a recordset from it.

Public Class Company

Public oCompany As New SAPbobsCOM.Company

Public Function getCompany(ByVal server As String, ByVal companyDB As String, ByVal serverType As SAPbobsCOM.BoDataServerTypes, _

ByVal dbUser As String, ByVal dbPasswd As String, ByVal companyLanguage As SAPbobsCOM.BoSuppLangs, _

ByVal userName As String, ByVal userPasswd As String, ByVal licenceServer As String, _

ByVal trusted As Boolean) As SAPbobsCOM.Company

Dim lRetCode As Integer

oCompany.Server = server

oCompany.CompanyDB = companyDB

' 1 = sqlsrv

oCompany.DbServerType = serverType

oCompany.DbUserName = dbUser

oCompany.DbPassword = dbPasswd

oCompany.UserName = userName

oCompany.Password = userPasswd

oCompany.language = companyLanguage

'// Use Windows authentication for database server.

'// True for NT server authentication,

'// False for database server authentication.

oCompany.UseTrusted = trusted

oCompany.LicenseServer = licenceServer

Try

'// Connecting to a company DB

lRetCode = oCompany.Connect

Catch

System.Diagnostics.Debug.WriteLine("company connect error")

End Try

Return oCompany

End Function

End Class

Former Member
0 Kudos

Thq you very much

is this the a2004 version or a2005

and can i have your e-mail adres so i can e-mail you directly i have a perposal voor you

benito

Former Member
0 Kudos

Is 2005A

sander@dresearch.de

Former Member
0 Kudos

hi gerd

iam new to sap b1 i tried your code to connect through asp.net its saying that you are not connected to company when i try to fetch data through businness object

i suspect the ByVal licenceServer As String which i provided might be wrong so can you help me by briefing what should i give over there

i also added the required references iam using vs2005

my code is as follows

testcompanyconnect.Company obj = new testcompanyconnect.Company();

obj.getCompany("192.168.3.119", "test", SAPbobsCOM.BoDataServerTypes.dst_MSSQL, "sa", "sa",SAPbobsCOM.BoSuppLangs.ln_English, "manager", "manager", "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056", false);

Response.Write("cONNECTED");

SAPbobsCOM.Documents doc = (SAPbobsCOM.Documents)obj.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

doc.DocNum = 1;

doc.GetByKey(1);

string STR = "C:
ASD.XML";

doc.SaveXML(ref STR);

in simple what should i give in the place of licenceServer parameter

Public Function getCompany(ByVal server As String, ByVal companyDB As String, ByVal serverType As SAPbobsCOM.BoDataServerTypes, _

ByVal dbUser As String, ByVal dbPasswd As String, ByVal companyLanguage As SAPbobsCOM.BoSuppLangs, _

ByVal userName As String, ByVal userPasswd As String, ByVal licenceServer As String, _

ByVal trusted As Boolean) As SAPbobsCOM.Company

Thanks in advance

Answers (1)

Answers (1)

Former Member
0 Kudos

Hey Benito,

If you look at the samples folder :

C:\Program Files\SAP\SAP Business One SDK\Samples

There are all kinds of examples to how you how to use .net and SAP. To use with ASP.net you will have to learn more about the DI server or write custom code.

Former Member
0 Kudos

Is it posible to make an sap order via the di server?

And what do you mean with custom code

Former Member
0 Kudos

Hey Bennie,

Sorry I do not have much experience with the DI server. By custom code I meant you would have to write an asp.net web application to work with teh DI API on the web site.

Former Member
0 Kudos

Is it posible to create an order in basic.net

Former Member
0 Kudos

Yes You can do many things with the SDK. Check out this folder on your machine: C:\Program Files\SAP\SAP Business One SDK\Samples

to find examples for order creation.