gous99
18th June 2002, 17:51
I'm using the stpapi.find() call from Visual Basic. It finds the record and do whatever I need to, but my problem is it does not return the proper value. In fact it always return a 0, even though it finds the record.

Is there anybody that faced that problem before, and found a solution?

lbencic
18th June 2002, 22:37
Is this the VB code posted below? Did you check into the posting about the stpapi.put.field command - you were showing stpapi.put.fields

If that's not the problem - did you try putting this through a standard Baan session to be sure the calls are valid before adding the VB layer. If that's not working, you can post that code. I know I for 1 am more familiar with the standard Baan version of the stpapi calls instead of VB. If it works through the Baan session, and not VB, at least we can narrow it down.

mark_h
18th June 2002, 23:53
Not sure, but I do not think the BaanObj.ParseExecFunction returns the value of the stpapi.find command. I am not sure how you test the success of the find command.

I tried searching the forum for an example, but could not find one.

Mark

mark_h
18th June 2002, 23:59
I think you want to check BaanObj.ReturnValue. I did this as a test with your code and got 1 when it found the record and two when it did not find it.

Mark

gous99
19th June 2002, 00:01
First thing, is make sure the reference to "Baan4 1.1 Type Library" is checked (in the references of the project).

After the stpapi.find call, all we have to do is the following

longVar = baanObj.ReturnValue


But, I have another one for you. with the stpapi.get.field, I can't get the value back in visual basic. When I look at the afs.log file, I can see the value is found, but in my VB code, the reference variable is still empty.

Anyone knows about this? Anyone can post here a code from VB that works fine with a stpapi.get.field call? Thanks

gous99
19th June 2002, 00:02
I was just posting my answer while you posted yours!!! Do you know anything about my other problem (stpapi.get.field)?

mark_h
19th June 2002, 00:22
There is an example in this forum. I will look for it.

Mark

mark_h
19th June 2002, 00:34
Follow the http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1168. This should give an example of how to use the baanobj.functioncall and parse the data.

Mark

alejandro
19th June 2002, 01:16
If the field you are trying to retrieve is string you have to define it in VB with enough 'room'. For example if it is a string with 16 characters, you have to set this variable as for example space(16), or better assign a string with 16 characters and try to check if the stapi.get.field call change this value. If it is a variable different than string, double, long or date field, also you can face problems if it is not set well.

You can check if your function call was right using BaaNObject.Error property. You can have this differents values after a ParseExecFunction:

0 No error
-1 Unknown DLL
-2 UnKnown function in DLL
-3 Syntax error in Function call
-10 Timeout reached

Hope this help

Andy..
12th July 2010, 13:50
Hi, I've spent a lot of time searching baanboard and trying the various solutions but still not joy! I reverted to a simple solution using the good old Areas session:

Dim retval As String
retval = Space(128)
Dim getfield As String
getfield = Space(30)

datarec$ = "datarec"
retVal2$ = "retval"

'AREAS TEST RETURN VAL...
'put area 'AZ, find , get desc
'put area
SessionName$ = "tcmcs0145m000"
FieldName$ = "tcmcs045.creg"
FieldValue$ = "001"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & FieldName$ & Chr(34) & "," & Chr(34) & FieldValue$ & Chr(34) & ")"

baanobj.ParseExecFunction "ottstpapihand", "stpapi.find(" & Chr(34) & SessionName$ & Chr(34) & ")"

errstr = baanobj.Error
'get desc
SessionName$ = "tcmcs0145m000"
FieldName$ = "tcmcs045.dsca"

baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & FieldName$ & Chr(34) & "," & Chr(34) & getfield & Chr(34) & ")"
tempstr$ = baanobj.FunctionCall
longVar = baanobj.ReturnValue

errstr = baanobj.Error
MsgBox (tempstr$)

baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & errmessage1 & Chr(34) & ")"


I have tried putting 'tempstr$ = baanobj.FunctionCall' after the find, and various messing with baanobj.error etc. In the afs.log it indeed seems to be working:


3dll->serv (getxml)
3dll->serv (starttcmcs0145m000100)
5serv<-4gl (init.ready)
tcmcs0145m000(5)-RUNNING:
LOGGING STARTED
11-01-2005
>tcmcs0145m000(5) put.field:tcmcs045.creg 001
>tcmcs0145m000 Find
3dll->serv (def.find5)
tcmcs0145m000(5)-RUNNING:def.find
5serv<-4gl (def.find01)
tcmcs0145m000(5)-RUNNING:
<tcmcs0145m000 record found (1)
>tcmcs0145m000 get.field:tcmcs045.dsca
<tcmcs0145m000(5) get.field:tcmcs045.dsca=Americas
>tcmcs0145m000 end.session
3dll->serv (end.program5)
tcmcs0145m000(5)-RUNNING:end.program
5serv<-4gl (end.program0)

but the results are tempstr$="stpapi.get.field("tcmcs0145m000",tcmcs045.dsca"," ") (30 spaces between the final quotes but baanboard is cropping them )

Any ideas?? Hopefully I'm missing something simple...

mark_h
12th July 2010, 16:53
I used your code(well except code 105 instead of 001) and it works for me. All I did was add the line below your tempstr$. From the screen shot you can see when I point to tempstr$ it has a value.

tempstr$ = BaanObj.FunctionCall
descr = Mid(tempstr$, 50, 32)

On my desktop I am using client BW 40c.087 and we are on 4c4 something like SP23 or 24.

Andy..
14th July 2010, 19:07
Hi Mark, thanks for your reply. I dropped the code onto a BaanIV bwclient PC and it works perfectly. Problem is, I need this to work with BAAN5! This must surely be possible, can anyone point me towards the Baan5 version of this get return?

Also Mark, where can I find the definition of the possible extensions 'BaanObj.*', such as: BaanObj.FunctionCall ??

mark_h
14th July 2010, 19:22
I have no idea where to get documentation like that. Everything I know has come from the baan excel examples or on this board. I do not know anything about baan 5 and how that might possible be fixed. Is it possible to put a baan iv client on the machines without impact anything for baan v(however that client or setup works).