arthur_info
29th December 2009, 18:59
Hello all,

First, thank you all by the attention...
I'm almost finished with a routine that will automatically generate quotes for purchase from the purchase requests using vb.net and integration with Baan IV. The problems are only 3:

1. The field "posi.d" can receive 1, 2 or 3 values, corresponding to "registered", "winner" or "loser". Any value that I place keeps always "registered" (1).

2. When I finish entering data, I try to run the BaanObj.Quit () but this command produces the message "The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))" after running the following commands: :
BaanObj.ParseExecFunction ("ottstpapihand ","stpapi.enum.answer ( "tdcotd109m000", tdcot00013.d, etol (dtyesno.yes)))
BaanObj.ParseExecFunction (ottstpapihand "," stpapi.insert ( "tdcotd109m000", 1, "& Chr (34) & sErrMsg & Chr (34) &") ")

3. The last problem is that Baan asks if the user wants to copy the text of the item for the new quote and the value that I need to put it's "yes", but always keeps "no", even if I use this command:
BaanObj.ParseExecFunction (ottstpapihand "," stpapi.enum.answer ( "& Chr (34) & sSession & Chr (34) &", tdcot00013.d, etol (dtyesno.yes)))

Any suggestion is very appreciated...

Best regards.

mark_h
30th December 2009, 18:14
Well for (1) I can only assume you are putting the correct value in the field since I do not have that session. So it could very well mean that 1 and 3 are related - do you have the baan session source code? You would need the source code to look at to see if it is causing the problems. For #3 you can always try setting the default value for the question to yes. The only issue there is that the user will now see the default as yes. Also this might not always work - there was one session I ran into that set the default value in the script and I could not override it. The best thing is to look at the baan source code and see if there is anything in it - and plus you can put it in debug mode to step thru it.

For #2 the only thing I can recommend is to make sure you have the latest client, porting set and stpapi clients. I have never really seen an error like that, so I really do not have a clue on it. You can always check with support.

arthur_info
5th January 2010, 14:30
Hello Mark,

I'm in trouble now... I've got the last updates of the components, but the error persists... I've discovered too that my company don't have the license to get support for this... I've tried a lot of ways to solve this problem but the errors persists... Don't you know any other guy that works with vb.net and AFS?

Best regards,

Arthur

mark_h
5th January 2010, 15:35
The only person I know of who uses VB is user Al Smith. I stopped investigating this method when Baan told me they would not support it. I do everything in Baan now.

Somethings to try, but no promises they will work:
(1) Try creating a library in Baan using the stpapi commands. See if this works, versus the API code in VB. This might help you trouble shoot problems like 1 and 3.
(2) If (1) does not work you might want to look at setting the default for that question to yes. Then for the other problem look at the ~vamsi source extender solution - this could help you figure out where the problem is on the posi.d field.

Both are lots of work and may help point to where problems exist. I really have no clue about the disconnect issue.

grzegorz
5th January 2010, 21:58
For question 1 and 3: Maybe you pass values to stpapi functions with improper type. For stpapi.put.field you have to use strings:
do: stpapi.put.field( "your_session", "posi.d", "2" ),
don't : stpapi.put.field( "your_session", "posi.d", 2 )
For stpapi.enum.answer try to use direct enum value, not casted to long:
do: stpapi.enum.answer ( "tdcotd109m000", tdcot00013.d, dtyesno.yes)
don't: stpapi.enum.answer ( "tdcotd109m000", tdcot00013.d, etol (dtyesno.yes)))

Hope it helps and sorry for my poor English.

arthur_info
6th January 2010, 16:46
Hello Grzegorz and Mark,

1 problem fixed!!!! Thanks a lot!!!!

About the enum.answer, the problem is that I was using
stpapi.enum.answer ( "tdcotd109m000", tdcot00013.d, dtyesno.yes)
and the correct is
stpapi.enum.answer ( "tdcotd109m000", "tdcot00013.d", 1)

Unfortunately the other 2 problems persists...

I'm using the command like you said:
Dim s as string
s = "stpapi.put.field("tdcotd109m000", "tdcot974.posi.d", "2")"
Call BaanObj.ParseExecFunction("ottstpapihand", s)

Actually I have a procedure that populate all the fields like that:

Public Shared Function PopulateBaanField(ByVal BaanObj, ByVal sSession, ByVal sTable, ByVal sField, ByVal sValue) As String
' Preenchendo o campo Baan com o valor indicado
Dim s
s = "stpapi.put.field(" & Chr(34) & sSession & Chr(34) & ", " & _
Chr(34) & sTable & "." & sField & Chr(34) & ", " & _
Chr(34) & sValue & Chr(34) & ")"
BaanObj.ParseExecFunction("ottstpapihand", s)
If BaanObj.Error <> 0 Or BaanObj.ReturnValue <> "" Then
MsgBox("Error inserting data." & vbNewLine & _
"BaanObj.Error = " & BaanObj.Error & Chr(10) & _
"BaanObj.ReturnValue = " & BaanObj.ReturnValue & Chr(10) & _
"BaanObj.FunctionCall = " & BaanObj.FunctionCall)
BaanObj.Quit()
Return BaanObj.Error
Else
Return ""
End If
End Function

And the use is in this way:

sField = "posi.d"
sValue = "2"
PopulateBaanField(BaanObj, sSession, sTable, sField, sValue)

One other topic is that a message DispInvoke failed, error = -2147352562 always appear during the process in a window with title "BW Messages", but apparently does not hinder the process... Other thing is that posi.d is an enum field... Is there any topic about this?

Thanks a lot again...

grzegorz
6th January 2010, 16:55
Is "posi.d" a table field or a standalone variable on the form? In case of standalone variable your PopulateBaanField function still adds a table name and a dot to "posi.d" - so field name is not "posi.f" anymore. Maybe it causes your problem?

arthur_info
6th January 2010, 18:30
Hello Grzegorz!

Another problem fixed!

"posi.d" is a field of table "tdcot974. I need to give my apologyze, because I discovered now that this field always becomes 1, when I set the record because the other values are automatically sent by baan according to another process.
Thus, the last and only problem is the 2: I can't run Baan.Quit () after the insertion:

"The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))"

after running the following commands:

BaanObj.ParseExecFunction ("ottstpapihand","stpapi.insert ( "tdcotd109m000", 1, "& Chr (34) & sErrMsg & Chr (34) &") ")
BaanObj.Quit() '--> crash!!!!


Thanks a lot for the attention ...

Arthur

arthur_info
6th January 2010, 19:41
Last problem fixed!!!!

I've discovered that when I use this sequence of commands the Baan.Quit() works well:
BaanObj.ParseExecFunction ("ottstpapihand","stpapi.insert ( "tdcotd109m000", 1, "& Chr (34) & sErrMsg & Chr (34) &") ")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & sSession & Chr(34) & ")")
BaanObj.Quit()

Thanks a lot for the attention...

Best regards,

Arthur

mark_h
6th January 2010, 21:51
That never even dawned on me since I always end sessions before closing the program. Thanks for posting the update. Something else I just thought of - for putting fields. The way I do enumerate domains is like this:

stpapi.put.field("tdilc4401m000","koor.f",str$(tdilc.koob.act.sfc))

I know you already solved all the problems, but what is weird is where some of the "(double quotes) go. THe formats Grzegorz posted are for Baan coding and I do not know how it transfers into VB. Again thanks for updating the thread - it may help someone else doing this in the future.

arthur_info
7th January 2010, 13:27
Hello Mark,

" (double quotes) in vb is represented by "Chr(34)" and when I use the function I put this to be in the correct format.
Ex.:
Baan:
stpapi.put.field("tdilc4401m000","koor.f",str$(tdilc.koob.act.sfc))
Vb:
BaanObj.ParseExecFunction ("ottstpapihand","stpapi.put.field(Chr34 & "tdilc4401m000" & Chr34, Chr(34) & "koor.f" & Chr(34), "str$(tdilc.koob.act.sfc)) ")
Where BaanObj is the Object in VB instantiated with this command:
Dim BaanObj As Object
BaanObj = CreateObject("Baan4.Application")

It is I who must thank you, you help me a lot. Some problem, you can contact me at arthur_info@yahoo.com.br.

Best regards,

Arthur