gous99
17th June 2002, 23:57
Hi, here is my VB code, I'm just trying to find a record in the customer table, and update a field.

The problem is that the return value of the stpapi.find() call is always 0, as if it doesn't find the record. The record exists in Baan, maybe I'm not doing something, or I forgot something in my calls, but if someone sees something wrong, it would be greatly appreciated.

Private Sub Command1_Click()
Dim objBaan As New Baan4.Baan4

Dim BaanSession, ErrStr As String
Dim FindRet As Long

Dim BaanKeyField, BaanUpdateField, BaanKeyValue As String

BaanSession = "tccom1101m000"
BaanKeyField = "tccom010.cuno"
BaanKeyValue = "RR"
BaanUpdateField = "tccom010.namb"
BaanUpdateValue = "This is a test"

objBaan.ParseExecFunction "ottstpapihand", "stpapi.put.fields(" & Chr(34) & BaanSession & Chr(34) & "," & Chr(34) & BaanKeyField & Chr(34) & "," & Chr(34) & BaanKeyValue & Chr(34) & ")"

FindRet = objBaan.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & BaanSession & Chr(34) & "," & Chr(34) & ErrStr & Chr(34) & ")")


objBaan.ParseExecFunction "ottstpapihand", "stpapi.put.fields(" & Chr(34) & BaanSession & Chr(34) & "," & Chr(34) & BaanUpdateField & Chr(34) & "," & Chr(34) & BaanUpdateValue & Chr(34) & ")"
objBaan.ParseExecFunction "ottstpapihand", "stpapi.update(" & Chr(34) & BaanSession & Chr(34) & ",1," & Chr(34) & ErrStr & Chr(34) & ")"
objBaan.ParseExecFunction "ottstpapihand", "stpapi.save(" & Chr(34) & BaanSession & Chr(34) & "," & Chr(34) & ErrStr & Chr(34) & ")"

objBaan.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & BaanSession & Chr(34) & ")"

objBaan.Quit
Set objBaan = Nothing

End Sub

alejandro
18th June 2002, 00:29
You use stpapi.put.fields, is a mistake in your post or you are using it in your script?

If I remember well, the right function is stpapi.put.field, without 's'