simona
6th June 2008, 13:26
Hello there,

I activated a standard session with stpapi.put.field("tfcmg4240m000", "batch", str$(batch)).
How can I get the process id of this session?
What I want to do is to see the session and I intend to use reactivate() function and for this I need process id.
I think that is better to use function act.and.sleep() but I don't know how to pass the argument Batch, because the called session is a standard one and I cannot use argv() to obtain the value of batch.

thanks a lot,
simona

george7a
6th June 2008, 14:12
Hi,

Take a look at the pstat function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_processes_pstat).

I hope it help,

- George

simona
6th June 2008, 14:20
Hi George,

The first agument of pstat() is pid, but the pid is what I want to get. The program name i have it, is tfcmg4240m000. I need to get pid.

tahnks :)
simona

george7a
6th June 2008, 14:26
I know :)

Pstat does not retrieve process info only, it also goes over all the process in your current bshell. The first PID you give it is "-1" as in the example.

If you look at the example in the end of the link, you will see how to go through all the running sessions in your PC. Then you can grab the process you need with all the info that you want.

- George

simona
6th June 2008, 15:46
Thanks,
you're right. i didn't give enough attention to the example.:p
now i can get the process id....

simona
6th June 2008, 17:10
Hi,
I tryed to see the activated session (with afs and reactivate())...
but doesn't work with the script bellow...

stpapi.put.field("tfcmg4240m000", "batch", str$(batch))
stpapi.put.field("tfcmg4240m000", "text.remittance", "Bonuri")

id_ses = -1
id_ses = pstat( id_ses, nume_ses, info_ses)
while id_ses > 0
if shiftl$(shiftr$(nume_ses))="tfcmg4240m000" then
|am gasit procesul.. si il activez
reactivate(id_ses)
id_ses = -10
else
id_ses = pstat( id_ses, nume_ses, info_ses )
endif
endwhile

I think that is better to use act.and.sleep() but I don't know how to transmit the batch to the called session.
Any idea?

simona

simona
6th June 2008, 17:25
I find it :p

id_ses = act.and.sleep("tfcmg4240m000")
put.var(id_ses,"batch",batch)
put.var(id_ses,"text.remittance", "Bonuri")
reactivate(id_ses)