kmcinc
25th June 2008, 23:13
A function I wrote using AFS is going through three sessions:
1. pspmg0202m000 (Report Production Batches Completed)
2. pspmg0207s000 (Report End-Items/Containers Completed) using stpapi.handle.proc
3. tdilc4113s000 (Maintain ILC Receipts) using stpapi.continue.process

All database actions are executed properly but despite my stpapi.end.session calls for those three sessions, they are stil running in the bshell when I do a 'ps'. The return message is empty and the return code is 1, so everything appears to be ok.

What's preventing the sessions from terminating? Why isn't the stpapi.end.session call not working?

Thanks for your input,
-tom

mark_h
26th June 2008, 15:06
Do you have the end sessions in the correct order? Make sure there is not a hung sub-session that you have not accounted for. Put everything in debug mode - make sure the sessions get started at the correct time. I have seen where some subsessions start on their own, then the first stpapi.put starts another process for the sub-session - and it still works. Then the stpapi.end does not kill both versions.

If you have source code you can debug each session to see if something is causing it to hand. I have had to use kill to end some subsessions. I do not know why the will not end and I do not have source code.

kmcinc
28th June 2008, 05:30
Mark,

i don't have source code either so debugging won't work, unfortunately. there are some other subsessions which pop up in the bshell since i'm using synchronized sessions such as the Report Production Completed session. I did not execute an 'stpapi.end' command for those because it is my understanding that they will close automatically when I end the 'main' subsession. I guess I'll have to just try out different combinations...

-tom

grzegorz
28th June 2008, 18:30
Maybe stupid, but..
When you process the same operations manually, session by session, are there any questions popping up? If yes, dont forget to set answers with
stpapi.enum.answer(..)

kmcinc
30th June 2008, 16:39
Thanks, Grzeforz, for your reply. There are in fact questions coming up when processing these sessions manually and I do have the 'stpapi.enum.answer' function call in my code.

kmcinc
2nd July 2008, 22:36
I modified the code and took out all subsession function calls. So here's what's left:

stpapi.put.field("pspmg0202m000", "pspmg001.orno", orno)
rc = stpapi.find("pspmg0202m000", error.msg)
stpapi.end.session("pspmg0507m000", error.msg)
stpapi.end.session("pspmg0202m000", error.msg)

When I look at the processes in the bshell, I still see 'pspmg0202m000' and 'pspmg0507m000' listed.
I also tried to add a 'stpapi.handle.subproc("pspmg0202m000", "pspmg0507m000", ignore)' call before the above code but that didn't do anything either. Any ideas?

kmcinc
7th July 2008, 23:02
here is the afs.log for the above code:

LOGGING STARTED
07-07-2008
>pspmg0202m000 handle.subproc pspmg0507m000 ignore
8dll->serv (getxml)
8dll->serv (startpspmg0202m000100)
11serv<-4gl (api.child.startedpspmg0202m0008)
11serv<-4gl (switch12)
12serv<-4gl (api.child.startedpspmg0507m00011)
12serv<-4gl (switch11)
11serv<-4gl (switch12)
12serv<-4gl (switch11)
11serv<-4gl (switch12)
12serv<-4gl (switch11)
11serv<-4gl (init.ready)
pspmg0202m000(11)-RUNNING:
8dll->serv (handle.subsessionpspmg0507m000411)
>pspmg0202m000(11) put.field:pspmg001.orno 180428
>pspmg0202m000 Find
8dll->serv (def.find11)
pspmg0202m000(11)-RUNNING:def.find
11serv<-4gl (switch12)
12serv<-4gl (switch11)
11serv<-4gl (def.find01)
pspmg0202m000(11)-RUNNING:
<pspmg0202m000 record found (1)
>psmpg0202m000 end.session
8dll->serv (afsscript: exit(8))

kmcinc
7th July 2008, 23:03
when I access the session manually, there is no question or prompt coming up of any kind. I simply open it, find a record and then close the session; no prompt, no message, nothing. So the AFS code should work properly.

kmcinc
7th July 2008, 23:43
meanwhile, i was able to put the standard Baan session 'pspmg0202m000' into debug mode as well and found that the stpapi.end.session function call did not trigger any of the end.program or abort.program sections! Why could be the reason for that?

mark_h
8th July 2008, 14:21
Do other options work? Like another find? How does the session normally end - I mean when using it manually? I notice pspmg0507m000 starts, but I don't see where it is ended before pspmg0202m000. At one point I had to end the display session prior to ending the main session.

kmcinc
8th July 2008, 22:34
Mark, the other options do work. When my code calls the stpapi.find function, the pspmg0202 debugger jumps in and lets me walk thru the code. when my code has control again and i call stpapi.end.session, the debugger does not respond.
Using the session manually and ending the session triggers the choice.end.program section.
As far as the pspmg0507 session is concerned, I do end the session prior to ending pspmg0202 ( i edited the code above accordingly).

mark_h
9th July 2008, 14:54
I can not think of anything else to try - I know one session I had to use the kill command. I would find the process id then kill that ID, it was the only way for me to get control again. I do recommend contacting Baan support.

kmcinc
10th July 2008, 00:04
I found the thread with your sample code to find and kill a process which I will try. Let's see if Infor can help.

Thanks for you help and suggestions!