Wilson Peña
26th April 2005, 20:28
Hi Everybody:


I'm testing Baan and Excel. I created a bottom with the following code:

The script run ok, but when I see the table, nothing happend. I suppose that I can Insert data, please urgent what is the problem,

I'm testing with Baan Vc.


Thanks


Private Sub BaaN_Click()
'
' Correr_sesion_de_baan Macro
'

Dim ssql As String
Dim erreur As String
Dim errmess As String
Dim baanobj As Object
Dim codigo As String
Dim descripcion As String


Dim i As Integer
Dim error As String

cRow = 4
cColumn = 3
dRow = 4
dColumn = 4

'If Worksheets("Conjuntos").Cells(cRow, cColumn) = "" Then
' MsgBox "Código Conjunto no puede ser vacío"
'Else
' codigo = Worksheets("Conjuntos").Cells(cRow, cColumn)
' descripcion = Worksheets("Conjuntos").Cells(dRow, dColumn)

do_update = "1"
codigo = "WPA"
descripcion = "Ingreso de Excel"
Set baanobj = CreateObject("Baan.Application.BaanERP")

' ssql = "stpapi.put.Field(" & Chr(34) & "tcmab0105m000" & Chr(34) & ", " & Chr(34) & "tcmab005.conj" & Chr(34) & ", " & Chr(34) & "UNO" & Chr(34) & ")"
ssql = "stpapi.put.Field(" & Chr(34) & "tcmcs0145m000" & Chr(34) & ", " & Chr(34) & "tcmcs045.creq" & Chr(34) & ", " & Chr(34) & codigo & Chr(34) & ")"
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)
' ssql = "stpapi.put.Field(" & Chr(34) & "tcmab0105m000" & Chr(34) & ", " & Chr(34) & "tcmab005.dsca" & Chr(34) & ", " & Chr(34) & "Creado desde visual" & Chr(34) & ")"
ssql = "stpapi.put.Field(" & Chr(34) & "tcmcs0145m000" & Chr(34) & ", " & Chr(34) & "tcmcs045.dsca" & Chr(34) & ", " & Chr(34) & descripcion & Chr(34) & ")"
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)

baanobj.ParseExecFunction "ottstpapihand", "stpapi.insert(" & Chr(34) & "tcmcs0145m000" & Chr(34) & "," & do_update & "," & Chr(34) & "errmess" & Chr(34) & ")"
errmess = Val(baanobj.ReturnValue)
If baanobj.error = 0 Then
MsgBox "Codigo de conjunto " & codigo & " añadido"
' Worksheets("Conjuntos").Cells(13, 3) = codigo
' Worksheets("Conjuntos").Cells(13, 4) = descripcion
' Worksheets("Conjuntos").Cells(cRow, cColumn) = ""
' Worksheets("Conjuntos").Cells(dRow, dColumn) = ""
End If
erreur = baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & "tcmcs0145m000" & Chr(34) & "," & Chr(34) & "errmess" & Chr(34) & ")")
'End If
End Sub

lakoon
28th April 2005, 13:56
Hello

What is the retrun value off stpapi.insert?
Did you check what is written to the AFS.LOG file?

/lakoon

Wilson Peña
29th April 2005, 16:09
Thanks for the reply.

The return value of the stpapi.insert is 0.

what may be wrong.


thanks

mark_h
29th April 2005, 16:46
Have you checked this post (http://www.baanboard.com/baanboard/showthread.php?t=15091&highlight=tcmcs0145m000) out? From it we can see that this does work. It maybe that in this case my mantra needs to be repeated.

lakoon
29th April 2005, 17:05
Hello

0 = no insert done. The error message should be filled with the reason.

You define:
do_update = "1"

I think you should try somthing like

do_update = 1, as the stpapi.insert function needs a long value at this position (true=1, false=0)

/lakoon

mark_h
29th April 2005, 18:29
I just noticed that you are using "tcmcs045.creq" as one of the fields - it should be "tcmcs045.creg". At least thats what it is on our 4c4 system. Found this while testing the stpapi code.

Wilson Peña
30th April 2005, 01:06
Thanks for the Reply.

Like said Mark, I made a mistake with the name of the variable tcmcs045.creg.

I fixed and now the script is ok.

Thanks.

Now I tested the same script with Baan IVC2 and olso is ok.

I have a doubt, all the functions can be use in C2?.

Some people said me that AFS don't work with C2.

Some one can explain if it's true?.


Thanks


Wilson

mark_h
2nd May 2005, 15:17
I think AFS does work with 4c2, but not with 4b2. Checking for the ottstpapihand library is one way to tell.