cancel
Showing results for 
Search instead for 
Did you mean: 

UI/DI - Store Procedures

Former Member
0 Kudos

Hi All,

VB.Net

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

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

Exit_FormLoad:

'cleanup

Set oCommend = Nothing

Set oRS = Nothing

'retval

Exit Sub

Err_FormLoad:

Call oComp.GetLastError(lErr, sErr)

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

Resume Exit_FormLoad

End Sub</i>

HTH

Regards,

Yaniv G.

SDK Consultant,

SAP Manage Israel.

Former Member
0 Kudos

Thanks Yaniv,

It works well. One small question.

How do i get the returned value?

I.e.

Dim sMystring as String

oCommend.Execute '// call sub execute

sMyString = oCommand (ReturnValue) ?

Regards Rayner

Former Member
0 Kudos

Hi again,

Sorry - I forgot to mention - you can find the returned value in:

sMyString = oCommend.Parameters.<u>Item(<b>0</b>)</u>.Value

Yaniv G.

Answers (0)