klesch
12th July 2002, 13:13
HELP!

I've just started to experiment with stpapi functions on Baan 5 c. I run into a problem at the very beginning.

I'm trying to get a simple example working with the following code. After calling stpapi.continue.process() function the error$ variable get a value of "Session not available".

Why? Session tidpl0201m000 was created by me and exists.

function stpapi.test()
{
string error$(64)

stpapi.continue.process("tidpl0201m000", error$)
if strip$(error$) <> "" then
message(error$)
endif
stpapi.end.session("tidpl0201m000")
}


Please, help!

alejandro
12th July 2002, 13:23
I think that before calling continue.process, you have to make session started.

Theorically any stapi call make the session to be current, but for continue.proccess, it is not neccesary to put value fields before?

Try to use a get.field call or better put values before continue and post your results.

I have to tell you that I work in c4, but I think this comment can be helpul for you. Hope

Good Luck.

klesch
12th July 2002, 15:44
I tryed with stpapi.put.field and stpapi.get.field functions. The session is responding.

But stpapi.continue.process does not do anything. The error message does not appear any more if calling stpapi.put.field first.

Do you have any further suggestions?

Is there any API related document that covers Baan 5 functionality? Does anybody have it?

mark_h
12th July 2002, 15:55
Follow the link (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=889) for a document. I think it is the one I downloaded off the board. There could be a more current version on the baan support site.

Since tidpl0201m000 is your session, I recommend putting it in debug mode and tracing what the problem is. Typically you fill the form fields then do a continue. Could you post the sessions script? Someone may see why the code does not work.

Good Luck!

Mark

klesch
12th July 2002, 16:22
Thank you for the link to the document. It's beeing printed. :)

I'm attaching two files (within script.zip):

1. tidpl0201m000.bc - it contains the complete script of the session that is being called with stpapi.* functions.

2. api_script.bc - it contains the script of the session that is using stpapi.* functions.

I had both scripts in debug mode. I noticed that stpapi.continue.process() does not do anything. With other words: choice.cont.process: on.choice: section within tidpl0201m000.bc never happens.

I really hope that somebody will know what is causing this.

mark_h
12th July 2002, 16:48
Have you all installed the latest solution for the API toolset? Also since we are on 4c3 I do not know anything about that stpapi.synchronize.dialog command.

Mark

gfasbender
12th July 2002, 18:24
In Baan 5, you need to use the function stpapi.form.command(), not stpapi.continue.process().

void stpapi.form.command(string session, long command.type, string command.prog, ref string err.mesg)

mark_h
12th July 2002, 19:39
I see that in the documentation now that you pointed it out. I will try to remember that when answering questions for Baan V function servers.

Suitably humbled. :)


Mark

klesch
13th July 2002, 20:18
Thank you for this hint.

And further... What are the arguments that I have to pass to stpapi.form.command() function in Baan 5 to get the same result as with stpapi.continue.process() in Baan 4?

Thanks in advance.

Originally posted by gfasbender
In Baan 5, you need to use the function stpapi.form.command(), not stpapi.continue.process().

void stpapi.form.command(string session, long command.type, string command.prog, ref string err.mesg)

alejandro
14th July 2002, 01:37
I think you have to use this code:
stpapi.form.command("tidpl0201m000", 5, "napolni.tidpl001",err.mesg)

5 for function call
2 for session call

klesch
14th July 2002, 10:42
I tried this but it didn't work until I declared the function as extern. Of course... :o

Originally posted by alejandro
I think you have to use this code:
stpapi.form.command("tidpl0201m000", 5, "napolni.tidpl001",err.mesg)

5 for function call
2 for session call

mark_h
14th July 2002, 19:37
Hi klesch,

Thought I would try again. Follow this link (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1227&pagenumber=2). Since I am not on 5c I hope this answers your question. I think they use stpapi.form.command("tidpl0201m000", 5, "exec.cont.process",err.mesg) - but check the link. I am sure if I got it wrong Gordon will correct me when he shows up. :)

Mark

klesch
15th July 2002, 14:54
Thank you for all your answers and hints until now. But I obviously need some more. :o

I'm writing a function zakljucevanje.operacij() which will use stpapi.* functions to start tisfc0530m000 session, find a record and then start a synchronized dialog tisfc0130m000.

The function is not done yet, but I noticed that something is not as I was expecting. The function starts the first and the second session and finishes both successfully. I checked this using debbuger and ottstpshell.

The problem is that my session hangs after this. This was not the case before using the stpapi.synchronize.dialog() function.

What's wrong?! :confused:

The following is the complete code of my session's script that I'm working on.

I'm looking forward to your replies.


declaration:

table ttidpl001
table ttisfc001

#pragma used dll ottstpapihand

#define SESS_1 "tisfc0530m000"
#define SESS_2 "tisfc0130s000"


before.program:
set.synchronized.dialog("tidpl0101s000")

functions:
function extern zakljucevanje.operacij()
{
string error$(64), error.code$(64)
long ret.val

if tidpl001.staa <> tcyesno.no then
mess("tidpl9001", 1)
return
endif

stpapi.put.field(SESS_1, "tisfc010.pdno", tidpl001.pdno)
stpapi.put.field(SESS_1, "tisfc010.opno", str$(tidpl001.opno))

ret.val = stpapi.find(SESS_1, error$)
if ret.val <> 1 then
message("Zapis ne obstaja.")
else
ret.val = stpapi.mark(SESS_1, error$)
if ret.val <> 1 then
message(error$)
else
ret.val = stpapi.synchronize.dialog(SESS_1, "modify", error$)
if ret.val <> 1 then
message(error$)
else
stpapi.put.field(SESS_2, "tisfc010.cmdt", str$(utc.num()))
stpapi.put.field(SESS_2, "qcmp.form", str$(tidpl001.qcmp))
stpapi.put.field(SESS_2, "qrjc.form", str$(tidpl001.qrjc))

while true
error.code$ = stpapi.get.mess.code(SESS_2, error$)
if isspace(error$) then
break
endif
endwhile
stpapi.end.session(SESS_2)
endif
endif
endif
stpapi.end.session(SESS_1)
}

mark_h
15th July 2002, 20:07
Under Baan 5c how to you know when sessions are snychronised? The document says If fields are sent to a single-occurrence session, which is synchronized with a multi-occurrence session, the values must be put after a stpapi.synchronize.dialog() call is issued to the multi-occurrence session, because otherwise the single-occurrence session is activated without a link to the multi-occurrence session.

So how do you know when to use the stpapi.synchronize.dialog and when not to? The above quote came from the stpapi.put.field session.

Mark