Skip to Content
author's profile photo
Former Member

UI/DI - Store Procedures

Hi All,


Can some provide a small sample of how to call a stored procedure and retrieve the returned result string using the SAPbobsCOM.Command object?

Regards Rayner

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 18, 2004 at 09:03 AM


    Here is a sample of VB6 code for executing a SP:

    <i>Private Sub Form_Load()

    Dim lErr As Long

    Dim sErr As String

    Dim oRS As SAPbobsCOM.Recordset

    Dim oCommend As SAPbobsCOM.Command

    On Error GoTo Err_FormLoad

    Set oComp = New SAPbobsCOM.Company

    oComp.Server = "(Local)" '1 Server name

    oComp.CompanyDB = "XXX" '2 Company name

    oComp.DbUserName = "sa" '3 DBUsername

    oComp.DbPassword = "" '4 DBPassword

    oComp.UserName = "xxxxxxx" '5 Username

    oComp.Password = "xxxxxxx" '6 Password

    If Not oComp.Connect() = 0 Then Call Err.Raise(-999, "Form Load", "Error contecting to DB")

    Set oRS = oComp.GetBusinessObject(BoRecordset)

    Set oCommend = oRS.Command

    oCommend.Name = "<Your Stored Procedure Name>"

    oCommend.Parameters.Item(1).Value = 1

    oCommend.Parameters.Item(2).Value = 60

    oCommend.Execute '// call sub execute

    '// get last error

    oComp.GetLastError lErr, sErr

    MsgBox lErr & " " & sErr



    Set oCommend = Nothing

    Set oRS = Nothing


    Exit Sub


    Call oComp.GetLastError(lErr, sErr)

    Call MsgBox("ERROR: " & lErr & " - " & sErr)

    Resume Exit_FormLoad

    End Sub</i>



    Yaniv G.

    SDK Consultant,

    SAP Manage Israel.

    Add comment
    10|10000 characters needed characters exceeded