mathew
6th August 2019, 20:41
Hi friends,

How to modify existing group id as dummy group id(given by us) to the called maintain po session which is running through afs code in background with another session.

Regards,
Mathew :confused:

mark_h
6th August 2019, 20:59
What are you calling the group id? Can you give us more information. I know when I start a process there is a group number (or id) associated with it. But I am not sure how to change that or why I would need to change it.

mathew
7th August 2019, 06:46
Hi Mark,

stpapi.end.session not ending the mainain po session and getting hang so added code to kill session with afs related group id for po session, but if opening standard session after the afs wrote main session means it is unable to find correctly the afs related po session and wrongly trying to kill the standard po session, also in this point getting hang

mark_h
7th August 2019, 14:41
If the stpapi.end is not closing the maintain po session then there could be something else wrong. A subsession or something is hanging open. I typically watch the processes in the back ground (using ps on start shell in option dialog) as I step thru my code. I made sure I account for controlling everything. Only once in all of my coding did I have to kill a session. It was the maintain pegging on maintain purchase orders(tcmcs9551s00b). This is part of our A&D extension and I encountered the error when we upgraded to 4c4. Also you might want to try searching on the sessions on this forum. You might find something that helps you. I would think killing the session would be your last choice - but below is how I call a session I wrote to do this. I actually thought I might have to do this more, but only found one place that calls it.


| code to call it
ppid = pid
baan.sess = "tcmcs9551s00b"
export("ppid",ppid)
export("baan.sess",baan.sess)
rc = activate("tuddc9120m000")
|basic code from tuddc9120m000
form.1:
init.form:
if background then
suspend(5000)
execute(cont.process)
endif

|****************************** CHOICE SECTION ***************************
choice.cont.process:
on.choice:
if not background then
check.all.input()
else
import("ppid",ppid)
import("baan.sess",baan.sess)
endif
find.a.process()
if background then
execute(end.program)
endif

function find.a.process()
{
long hold.pno
long pno
long info(256)
string pname(15)

sess.found = false
| message("%d",pid)
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
}

mark_h
7th August 2019, 14:42
Forgot to mention the code basically traverses the processes and finds the exact session to kill.

mathew
8th August 2019, 13:49
Hi Mark,

I have not understood which pid you are exporting, please give me with screenshot and script in detail. I am using kill.pgrp() to afs tdpur4101m000, when afs is running in the means if i open standard po gui session it getting hanging.

Please give me any clear solution.

Regards,
Mathew

mark_h
8th August 2019, 15:07
This is one small segment of a very large program. pid is a predefined variable for the current process. All you really need to do is put this in your session.

function kill.a.process()
{
long hold.pno
long pno
long info(256)
string pname(15)

ppid = pid
baan.sess = "tcmcs9551s00b" ||||<<<<<<<<<----------Put your session here.

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
}


PS - I actually have a piece of code in my session that tells them that have to go close certain sessions before you can run my AFS code.


form.1:
init.form:
if check.processes() then
message("Please close tdpur4101m000(Maintain Purchase orders) and tdpur4107s000(Maintain Purchase Order Lines, before running this session.")
execute(end.program)
endif
functions:
function domain tcbool check.processes()
{
long hold.pno
long pno
long info(256)
string pname(15)

pno = 0
hold.pno = pno
pno = pstat (pno, pname, info)
while pno > 0
hold.pno = pno
pno = pstat (pno, pname, info)
if strip$(pname)="tdpur4101m000" or
strip$(pname)="tdpur4107s000" or
strip$(pname)="tdpur4503s000" or
strip$(pname)="tdpur4107s000" or
strip$(pname)="tdpur9151s00b" then
return(true)
endif
endwhile
return(false)
}