cancel
Showing results for 
Search instead for 
Did you mean: 

DI development without ADD-ON

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member201110
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Owen Slater,

Thank you very much for your reply.

I was just not sure whether the add-on is a must for any DI transaction. I have lot of sample codes with me, but was not sure whether I could go ahead with the development.

Your reply cleared my doubts.

thanks

sriram