RafaPros
25th October 2016, 10:29
He probado con todas las posibilidades que he encontrado en el foro y no hay manera de conseguir que funcione correctamente:

Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc001.cprj" & Chr(34) & "," & Chr(34) & codobra & Chr(34) & ")")
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc001.mitm" & Chr(34) & "," & Chr(34) & articulo & Chr(34) & ")")

If Baanobj.Error <> 0 Then
ErrDon = "Error al poner valor de Obra y Pieza"
MsgBox("Baan IV automatización " & Baanobj.Error & vbCrLf & "Valor de retorno de la función: " & Baanobj.Error.ToString & vbCrLf & "Donde: " & ErrDon)
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & Sesion & Chr(34) & ")")
Baanobj.Quit
Baanobj = Nothing
Exit Sub
End If

RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & valor & Chr(34) & ")")
Dim tempstr2 = Baanobj.FunctionCall
' MsgBox("PARADA DE COMPROBACION, RESULTADO DE FIND = " & tempstr2)
If Baanobj.Error <> 0 Then
ErrDon = "Error en la búsqueda de la OF " & OF_cod
MsgBox("Baan IV automatización " & Baanobj.Error & vbCrLf & "Valor de retorno de la función: " & Baanobj.Error.ToString & vbCrLf & "Donde: " & ErrDon)
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & Sesion & Chr(34) & ")")
Baanobj.Quit
Baanobj = Nothing
Exit Sub
End If
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.get.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc001.pdno" & Chr(34) & "," & Chr(34) & valor & Chr(34) & ")")
If V_pdno <> CInt(tempstr2) Then
MsgBox("Hay un problema entre el número de orden leida en el grid (" & V_pdno & ") y el número obtenido en BaaN (" & CInt(tempstr2) & ")")
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & Sesion & Chr(34) & ")")
Baanobj.Quit
Baanobj = Nothing
Exit Sub
' V_pdno = CInt(tempstr2)
End If
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "qdlv.frm" & Chr(34) & "," & Chr(34) & valor & Chr(34) & ")")
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc001.dldt" & Chr(34) & "," & Chr(34) & Temp_fecha1 & Chr(34) & ")")
Baanobj.ParseExecFunction("ottstpapihand", "stpapi.get.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc001.qrdr" & Chr(34) & "," & Chr(34) & valor & Chr(34) & ")")
tempstr = Baanobj.FunctionCall
tempstr = Mid(tempstr, 25 + Len(Sesion) + 13, 3)
total = Val(tempstr)

Baanobj.ParseExecFunction("ottstpapihand", "stpapi.get.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "qdlv.frm" & Chr(34) & "," & Chr(34) & valor & Chr(34) & ")")
Dim tempstr1 = Baanobj.FunctionCall
tempstr1 = Mid(tempstr1, 25 + Len(Sesion) + 8, 3)
cantidad1 = Val(tempstr1)

'Controlamos que la serie de " & tempstr2 & " esté o no completa " & cantidad1.ToString & " de " & total.ToString)
If cantidad1 = total Then
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "comp.frm" & Chr(34) & "," & Chr(34) & "1" & Chr(34) & ")")
Else
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "comp.frm" & Chr(34) & "," & Chr(34) & "2" & Chr(34) & ")")
End If
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02023" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02024" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02029" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.parseexecfunction("ottstpapihand", "stpapi.handle.subproc(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & subsesion & Chr(34) & "," & Chr(34) & "add" & Chr(34) & ")")
If Baanobj.error <> 0 Then
MsgBox("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Error al lanzar la subsesión " & subsesion & ", Handle = " & Baanobj.error & " obj " & Baanobj.ToString)
End If
'*******************************************************************************************************************
'* 25/10/2016 - Rafa Pros - Esta sección se utiliza para probar las posibles soluciones encontradas *
'* No se corresponde con lo que es la secuencia lógica de instrucciones *
'*******************************************************************************************************************
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & Sesion & Chr(34) & ")")
If RetVal <> 0 Then
MsgBox("*** ERROR *** end.session tisfc0202m000")
End If

MsgBox("PARADA DE COMPROBACION, ENTRADA EN PUESTA DE DATOS 4113 - QSTC, SUBSESIÓN = " & subsesion)

Hasta aquí, se supone que, funciona bien. No da ningún tipo de error,
En el momento que pasa el mensaje de comprobación y cuando, supuestamente, hace la siguiente línea de código se queda colgado sin mensajes de error:
retval3 = Baanobj.parseexecfunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & subsesion & Chr(34) & "," & Chr(34) & "tdilc402.qstc" & Chr(34) & "," & Chr(34) & cantidad & Chr(34) & ")")
If retval3 <> 0 Then
MsgBox("Retval3 Put qstc = " & retval3)
End If

Agradeceré que alguien me eche una mano.

mark_h
25th October 2016, 19:45
I went a head and left this post here. If you can put it in English you might get some responses. I don't have access to a translator here at work. Will try later.

mark_h
26th October 2016, 04:25
Well we do not run session tdilc4113m000 from session tisfc0202m000 - we do not build lots. But I do recall when we do receipts it does pop up. I also recall I had to do something different for that session. Not sure if I posted that on here or not - let me search.

mark_h
26th October 2016, 04:39
Is all of the code there? The reason I ask is I see where you put all of the fields on tisfc0202m000, but I do not see where you actually execute a save, update or continue on the session where it would initiate tdilc4113m000. What I see is this(I edited out one error code check for simplicity):

If cantidad1 = total Then
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "comp.frm" & Chr(34) & "," & Chr(34) & "1" & Chr(34) & ")")
Else
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "comp.frm" & Chr(34) & "," & Chr(34) & "2" & Chr(34) & ")")
End If
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02023" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02024" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & "tisfc02029" & Chr(34) & "," & "1" & ")")
RetVal = Baanobj.parseexecfunction("ottstpapihand", "stpapi.handle.subproc(" & Chr(34) & Sesion & Chr(34) & "," & Chr(34) & subsesion & Chr(34) & "," & Chr(34) & "add" & Chr(34) & ")")
RetVal = Baanobj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & Sesion & Chr(34) & ")")
If RetVal <> 0 Then
MsgBox("*** ERROR *** end.session tisfc0202m000")
End If

Basically what I see is put fields to tisfc0202m000, if all went well then do an end session. So you do an handle.subproc on the subsession tdilc4113m000, but then end 4113. That might be why you put field is hanging.

On my system if I put something like this in debug mode I can get to the option dialog box from the log in. I can do a ps as I step thru the code to make sure the session is still running and when a subsession gets kicked off.

mark_h
26th October 2016, 04:43
Should have searched first - see this link http://www.baanboard.com/baanboard/showthread.php?t=31085 that shows code that works. See how they have a continue in the process. Now as for what fields they put versus what you put you will need to figure out. I am not sure of the differences and all of the questions.

RafaPros
26th October 2016, 17:15
thank you very much for your answers Mark

Excuse my bad English.
Attached you the complete code. The link to the solution set I had already seen and I tried but did not work either.

I have given many laps do not know if the code attached will be entirely correct.

regards