cancel
Showing results for 
Search instead for 
Did you mean: 

Add draft through SDK

Former Member
0 Kudos

Hi Experts,

I have build a MS Access Form and a Button after_click event. I like to add the SAP draft after the user click the Button.

I have create recordset but after I click the button, it said I havn't connect to company.

How to connect SAP company(which log on already) in MS access .

Thanks

Gary

Edited by: garywong0224 on Feb 15, 2012 10:55 AM

Accepted Solutions (1)

Accepted Solutions (1)

Johan_H
Active Contributor
0 Kudos

Hi Gary,

The basic steps to do what you are trying to do are as follows:

1. Add a reference to the DI API to your coding project. (apparently you got this done)

Then in your code:

2. Get the necessary data to perform business logic (apparently you got this done as well, with a record set)

3. Connect to the B1 system using an adaptation of the example code from your SDK installation. You should be able to find it somewhere around here: C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\01.BasicOperations\2003\*

4. Create a new document based on your business logic

5. Add the new document.

6. Dispose of the document object

7. If necessary repeat steps 4 - 6

8. Disconnect from B1 and dispose of all remaining B1 objects

9. Live happily ever after.

If you have the SDK installed, there will be examples for each step on your PC (C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\).

Just to make your own life a lot easier, I warmly suggest that you consider using VB.NET instead of MS Access's VBA. MS Visual Studio 2010 Express is free and can be downloaded from the internet. If you already know VBA it should only take you a week or two to learn.

Using VB.NET or C# has the added advantages that many many more people will be able to help you, and the internet is filled with tutorials and example code.

For printing purposes you can always connect MS ACCESS to your .NET application.

Good luck,

Johan

P.S. Just as a matter of interest, how did you manage to reference the DI API in MS Access ?

Former Member
0 Kudos

Thanks Johan

Is your solution can also applied on VB express 2010.

Those example are for 2003 .

I use SAP 8.8 and VB express 2010 as develop enviroment. Do you have sample code for it.

Thanks a lot

Gary

Former Member
0 Kudos

Hi Gary

No need to worry , the samples will be upgraded to the latest version of .net as soon you open any of the sample.

You just need to reimport the SAP dll.

Regards

Former Member
0 Kudos

Hi Pari

How to reimport SAP dll?

Sorry for the easy question.

Thanks

Regards

Gary

Johan_H
Active Contributor
0 Kudos

Hi Gary,

Just open the project's properties window: Project > [project name] Properties

and then the References tab page. Somewhere at the top you should find the reference to the DI API.

Remove this reference, and add it again.

Regards,

Johan

Answers (1)

Answers (1)

Johan_H
Active Contributor
0 Kudos

Hi Gary,

You say that you are logged on already. Could you please post the code you are using to connect to the company ?

Regards,

Johan

Former Member
0 Kudos

Hi Johan,

Thanks for your reply. what I means is I have logged in SAP client directly double click SAP Business One button. Not through MS access. I don't know what the code is. Thanks

Gary