on 10-18-2007 5:37 AM
Hi,
Is it possible to create a DI transaction in SBO without creating an ADD-ON?
My intention is to create a quotation transaction directly from an EXCEL file with the help of VBA macro.
Is it possible to create such a transaction without the involvement of creating an add-on? There are no forms required. The data will be first checked thoroughly in the excel sheet and the same will be imported directly to SBO as a new quotation.
I appreciate, if someone could give me some sample code for such a transaction
sriram
Hi Sriram,
Yes, you can use VBA in Excel to create transactions in SBO by using the DI API. I do it all the time for various tasks rather than using DTW or other tools. You need to add the DI API reference to the VBA project and then you can create an instance of the Company object to connect to SBO. Once connection is complete then you can use any of the DI API objects. Normally I store the database connection properties at the top of the spreadsheet and place a button on the sheet to trigger the code.
Here's a basic example:
Option Explicit
Public oCompany As SAPbobsCOM.Company
Public oDoc As SAPbobsCOM.Documents
Public sErrMsg As String
Public lErrCode As Integer
Public lRetCode As Integer
Sub Execute()
Dim iMsg As Integer
Set oCompany = New SAPbobsCOM.Company
oCompany.Server = ThisWorkbook.Sheets(1).Cells(2, 2).Value
oCompany.DbUserName = ThisWorkbook.Sheets(1).Cells(2, 4).Value
oCompany.DbPassword = ThisWorkbook.Sheets(1).Cells(2, 5).Value
oCompany.CompanyDB = ThisWorkbook.Sheets(1).Cells(2, 3).Value
oCompany.UserName = ThisWorkbook.Sheets(1).Cells(2, 6).Value
oCompany.Password = ThisWorkbook.Sheets(1).Cells(2, 7).Value
oCompany.DbServerType = dst_MSSQL2005
'// Connecting to a company DB
lRetCode = oCompany.Connect
If lRetCode <> 0 Then
iMsg = MsgBox(oCompany.GetLastErrorDescription(), vbOKOnly, "Error")
Else
CreateDocuments
End If
oCompany.Disconnect
End Sub
Sub CreateDocuments()
On Error GoTo errortrap
'Code to generate your document goes here
Exit Sub
errortrap:
ThisWorkbook.Sheets(1).Cells(i, 5).Value = CStr(Err.Number) & " - " & Err.Description
Err.Clear
End Sub
Private Sub bUpdate_Click()
Execute
End Sub
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.