saumya
24th April 2015, 07:34
Is there a way to know if session started from AFS?
I am killing one session strted by AFS, but if the same session is opened manually. the kill command is killing manual started session.
My requirement to kill session started by FAS.
Thanks.
sachinbaan
24th April 2015, 08:55
hi,
pre defined variable is available, "api.mode"
ex.
if api.mode then
|* Session is running through AFS
endif
saumya
24th April 2015, 09:33
Hi Sachin,
I have developed one process session, which will call standard session and kill(as stpapi.end command is not working and client doesnt want to update patches).
function find.a.process(string baan.sess(15))
{
long hold.pno
long pno
long info(256)
string pname(15)
boolean sess.found
sess.found = false
pno = 0
hold.pno = pno
pno = pstat (pno, pname, info)
while pno > 0 and not sess.found
hold.pno = pno
pno = pstat (pno, pname, info)
if strip$(pname)=strip$(baan.sess) then
kill(hold.pno)
sess.found = true
endif
endwhile
}
I need to kill session invoking through AFS.
sachinbaan
24th April 2015, 10:11
hi,
I did following to overcome this problem.
Note: If you know which session is invoking through AFS, this will work.
long info(PSMAXSIZE), procid, ids, ret
string progname(13)
procid = -1
procid = pstat( procid, progname, info )
while procid >= 0
procid = pstat( procid, progname, info )
if progname = "tdpur4100m900" or progname = "ltfin1151m000" then
kill(ids)
endif
ids = procid
endwhile
saumya
24th April 2015, 10:22
Hi,
This is what I am doing. But if there is another session started with same code, kill command will kill that session too.
bhushanchanda
24th April 2015, 11:14
Hi,
Not sure if you are looking for this but check if it helps -
In before.program of the called session, you can try using
string parent.prog(14)
import("prog.name$", parent.prog)
if trim$(parent.prog) = "your_calling_session" then
end()
endif
saumya
24th April 2015, 11:28
Hi Bhushan,
As I am calling session, cant modify script of standard session.
bhushanchanda
24th April 2015, 12:03
Oh I see.
Try this -
id = pstat(id,progname,info)
while id >= 0
id = pstat(id,progname,info)
if trim$(old.progname) = "ottstpapiserv" and trim$(progname) = "tcibd0501m000" then
kill(id)
endif
old.progname = progname
endwhile
You can just try tweaking the code a little. Its just that, you need to go through the processes. AFS session's will be under ottstpapiserv so, you can go and kill the processes under them. But again, it might kill other AFS sessions running parallely, so you need to chose wisely the search and kill method. (I haven't tested it) But you can create your own logic to make it work.
Edit - The following code works for me without any issues. I am not using stpapi.end.session() here.
stpapi.put.field("tcibd0501m000","tcibd001.item.segment.1","154237")
stpapi.find("tcibd0501m000")
progname = "tcibd0501m000"
id = -1
id = pstat(id,progname,info)
while id >= 0
id = pstat(id,progname,info)
if trim$(old.progname) = "ottstpapiserv" and trim$(progname) = "tcibd0501m000"then
kill(id)
kill(old.pid)
endif
old.progname = progname
old.pid = id
endwhile
saumya
24th April 2015, 13:04
Thanks Bhushan.
Issue resolved, in my code only i used pid instead of pno.
Thanks for giving one more idea.