r_nagu
8th August 2002, 23:07
Hi Guys,
I have a question on handling sub sessions using AFS.

I am trying to automate Match and Approve process for Purchase Orders. Now, I was able to automate the process using AFS till the Matching stage but I am having some problems when it comes to Approving. When I am back on the main session (tfacp1131m001) after Matching the PO, I am using the following code to get into Approve session.

Start baan code:

stpapi.handle.subproc(“tfacp1130m001”, “tfacp1140s000”, “add”)

stpapi.handle.subproc(“tfacp1140s000”, “tfacp1141s000”, “add”)

stpapi.application.option(“tfacp1130m001”, 1, 0, err.msg)

message(“Procssing”)

End baan code:

As soon as the line stpapi.application.option(“tfacp1130m001”, 1, 0, err.msg) is executed, the program hangs. The reason is that, when “Approve” button is hit on the screen, you are zoomed to two session (tfacp1140s000 and tfacp1141s000) at the same time and I am not able to get the control of one of the zoom session (tfacp1141s000).

Do you guys have any ideas?


Appreciate your feedback.

Thanks,
Nagesh

mark_h
8th August 2002, 23:50
Just wondering what would happen if you moved your stpapi.application.option in front of the stpapi.handle.subproc for tfacp1141s000?

I am not familiar with this process, but do you have to put data into both the tfacp1140s000 and the tfacp1141s001 session? Just wondering if maybe you could kill one of them.

Last but not least try a stpapi.zoom to the tfacp1140s000 session. I do know in one function server I did (purchase order) I had to use stpapi.handle.subproc on the maintain reason code, and then stpapi.zoom for the distribution, even though the baan script did a zoom.to for both sessions. Never did figure out why that worked, but it did give me control of the distribution session. You could try this to see if it gives you control of the tfacp1140s000 session.

Just some guesses.

Mark

r_nagu
9th August 2002, 16:25
Mark,
Thanks for the suggestions.

I don’t have to enter the data in session tfacp1141s000 up front. I can kill it so that I will be on session tfacp1140s000 and then can go back to session tfacp1141s000 and maintain the data.

But, the problem is that I am not able to kill the session tfacp1141s000. I tried the following code

Start baan code:

stpapi.handle.subproc(“tfacp1130m001”, “tfacp1140s000”, “add”)

stpapi.handle.subproc(“tfacp1140s000”, “tfacp1141s000”, “kill”)

OR

stpapi.handle.subproc(“tfacp1130m001”, “tfacp1141s000”, “kill”)

stpapi.application.option(“tfacp1130m001”, 1, 0, err.msg)

message(“Processing”)

End baan code:

I am still able to get the control back.

Any ideas?

Thanks,
Nagesh

mark_h
9th August 2002, 17:47
I found this in the AFS document I have:


stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret = 1 then
stpapi.handle.subproc("dtfsa1501m000", "dtfsa1201m000", "add")
stpapi.zoom.option("dtfsa1501m000", 2, "dtfsa1201m000", error.msg)
stpapi.continue.process("dtfsa1201m000", error.msg)
endif



So maybe what you need is:


stpapi.handle.subproc("tfacp1130m001", "tfacp1140s000", "add")
stpapi.zoom.option("tfacp1130m001", 2, "tfacp1140s000", error.msg)
stpapi.application.option(“tfacp1130m001”, 1, 0, err.msg)


Or maybe something like:

stpapi.handle.subproc("tfacp1130m001", "tfacp1140s000", "add")
stpapi.zoom.option("tfacp1130m001", 2, "tfacp1140s000", error.msg)
stpapi.handle.subproc("tfacp1140s000", "tfacp1141s000", "add")
stpapi.application.option(“tfacp1130m001”, 1, 0, err.msg)


I may have plenty of ideas, just none of them may work. Also you might want to check with Baan support to see if anyone has logged a problem like this. I looked real quick for a solution, but I did not see one.

Also you may even want to try a stpapi.zoom from the tfacp1140s000 to tfacp1141s000 session.

Mark

r_nagu
9th August 2002, 19:34
Mark,
For some reason look’s like AFS is not able to handle when more than one sub sessions are started from a main session. I tried you suggestions and it can not move pass the first sub session (control is not returned back to the main program).

Anyway, I was able to solve my problem with a work around. The reason why session tfgld1140s000 was automatically zooming to session tfgld1141s000 was because of Fiscal Year not been set in the session tfgld1140s000. So, I set the fiscal year in this session itself and now I am not zoomed to session tfgld1141s000 automatically.

I will try to play around with this type of situation some time later and will let you know what I find out.

Thanks for your help,
Nagesh

mark_h
9th August 2002, 20:30
Thanks for the reply and I look forward to the update. I know when I used some of the tfgld sessions It started different sessions than you mentioned. I was also able to just end a few of them like tfacp1130s000. They were not needed for what I was doing.

Mark