popeye
23rd January 2002, 23:29
Hi,
Is it possible to change the Parent Process ID (ppid) of a
process?
Thanks.
Cheers,
Madhu
patvdv
23rd January 2002, 23:40
I don't think you can do this. PID and PPID assignments are managed and stored in the running kernel structures so unless you hack these I would not know any other way. Why would you want to change that though?
If anyone does know a way, I would be happy to know how :)
popeye
23rd January 2002, 23:53
Ok ... here is my problem.
We have a session for Approving Purchase Reqs.
Assuming the user is logged on to Company 800.
So ... in this session he'll be viewing the records for Company 800.
Now he wants to view the info for Company 815.
This is fairly simple for him. All he has to do is
1. Close the session.
2. Change the Company (Menu Browser).
3. Start the session again.
For some vague reason, my client is not willing to do this.
Too much effort - It seems :) Grrrrrrrrr
I tried convincing him --- No luck.
He wants to change the Company without exiting the session.
I do not want to use tablename._compnr etc in the script.
The program logic is pretty complex. I do not want to break my head over it.
I thought of switch.to.company()
That does not suit my needs.
Is there any other way?
Please let me know.
Thanks.
Cheers,
Madhu
patvdv
24th January 2002, 00:02
Madhu,
I can't see the connection between a process PPID and the Baan company number in a client process. I think your client is refusing to accept standard Baan functionality :D
I don't know if this is possible using Baan code but I am sure there are other people who can answer that. Any takers?
popeye
24th January 2002, 01:07
Hi Pat,
Here is the link between PPID and the problem I am trying to
solve.
I was trying to do the following:
1. Whenever the user selects the new company, I capture
it in free$. I also store the PID of the current process in
free$.
2. I activate/zoom to the same session.
3. In the "before.program", I chk if free$ has a valid
company+PID.
If yes, I do the following.
a) Kill the original session (PID is stored in free$).
b) Switch to the New Company (switch.to.company)
Now I have the new instance of the session with info from
the "new" company.
But ... when I kill the "old" session, it's still there in the
background since it's child ("new" session) is still active.
Hence I wanted to "delink" the two processes.
... Hence the Question? How do I play around with the PPID?
Cheers,
Madhu
mark_h
24th January 2002, 03:42
That seems like a lot of work to just switch the company. The way I did it was to take all of my functions and make them a library where I pass the company number. My user finally agreed to input the company he wanted the data from. The problem was that he only wanted certain data from our simulation company. Is there a reason why you could not set a button on the form and do a switch .to.company - toggle,ask for company or something.? I know you said you did not want to use switch.to.company, but it seems that offers the best solution so far.
Sorry, but I do not know of anyway to do this using process id's. If you do figure out a way to do this using PID's then please post it.
Good Luck!
Mark
victor_cleto
24th January 2002, 12:33
Why don't you create a specific BW settings that enable that client to start within the correct company number and also the session he wants to run straight away?
Like this, he doesn't need to clos the current, he just needs to login again with a specific BW settings.
You can even prepare two specifc sessions, one that connects to the correct 800 and another to the 815, just in case he needs to see the data from 800 while working in the 815!
parag2679
24th January 2002, 17:00
Hi Madhu,
Could u just check whether the functioon set.pgrp() can be useful in ur case. It can be used as set.pgrp(some.pid,some.pid) to set the group id of the process(some.pid) to a new group id
I had used it in combination with the related functions to start a independent process from a parent process.
Regards,
Parag
popeye
24th January 2002, 20:17
Victor ... My client does not want to use two sessions.
He wants just one session open.
He wants to toggle between the Companies within the session.
Call it weird ... call it crazy ... He wants it.
lbencic
24th January 2002, 23:51
What do you not like about the "switch.to.company" command? I have found it to work quite well, but I am usually doing process routines. Is the problem the data on the form comes in with the old company? If so...try issueing the switch.to.company command, then a "refresh()" command or something else to do the lookup again.
popeye
25th January 2002, 00:13
Hi,
Thanks for the posts.
Here is what I don't like about switch.to.company.
Although I m able to change the company, the "top bar" (for lack of a better term) still shows the old company.
See the attached pic (I have changed to 475, but the Bar still shows 400).
Unless somebody knows how to make that work.
Also I have a query extension (before.program).
How will I execute that part, when I do a switch.to.company?
Hence I was activating another instance and
1. changing the Company in the before.program section
2. killing the "old" session
But with this, the old process remains hanging (till I close out the
child session).
Thanks.
Regards,
MAdhu
vgobiraj
25th January 2002, 00:18
Within the session there must be an choice/option to change company.
1. Specify New Company
2. activate("session") | Activates the same session
3. execute(end.program) | This will end the current program
Other solution can be if the functionality permits then
there can be logical table sharing. So in one screen user
sees data from both the companies.
popeye
25th January 2002, 00:33
here is the pic
vgobiraj
25th January 2002, 01:43
I tried this script and it opens the session in the specified company.
In ur case I think u also need execute(end.program) after
activate.
function main()
{
switch.to.company(814)
activate("tcmcs0145m000")
}
popeye
25th January 2002, 02:26
Gobiraj ... u r correct.
Anyways ... I got a very simple solution from ~Vamsi.
Will post it after I am done with it.
Cheers,
Madhu
popeye
25th January 2002, 02:38
Hi,
Here is ~Vamsis solution.
I have a Control Session which calls the Main Session.
The Control Session does not have a form linked to it.
Here is the code in tdpuro143m001 (Control Session).
declaration:
domain tccomp hold.comp
before.program:
hold.comp = get.compnr()
while (1)
if hold.comp = 0 then
exit()
else
switch.to.company(hold.comp)
hold.comp = lval(zoom.to$("tdpuro143m002", Z.SESSION, "tdpuro143m001", "", 0))
endif
endwhile
Here is the code in tdpuro143m002 (Main Program)
choice.user.0: | 400
on.choice:
exit(400)
choice.user.1: | 475
on.choice:
exit(475)
It works just fine (except for the flash when the sessions close and open).
Thanks a lot Vamsi for the easy fix.
Modified the posting with the addition of code tags.
~Vamsi
~Vamsi
25th January 2002, 05:23
Madhu,
I was wondering if you could do away with the second button. Just rename the first button to "Switch Company".
Your code would then become
choice.user.0: | 400
on.choice:
if curr.company = 475 then
exit(400)
else
exit(475)
endif
Am writing from home. Do not remember the predefined variable for the current company number. Replace curr.company with that variable :).
Alternatively you should atleast disable the button for the active company. I do not remember if it is possible to disable buttons in Baan IV.
popeye
25th January 2002, 23:56
before.program:
hold.comp = get.compnr()
while (hold.comp <> 0)
switch.to.company(hold.comp)
hold.comp = lval(zoom.to$("tdpuro143m002", Z.SESSION,
"tdpuro143m001", "", 0))
endwhile
Code tags added.
~Vamsi
I am not sure if this is available in your BaaN Version, I think you can also use -
substitute.session() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_substitute_sessions_substitute_session)
Substitute session sample program (http://www.baanboard.com/programmers_manual_baanerp_help_functions_substitute_sessions_example)
something new to explore...