david7
19th December 2006, 18:02
Hello All,
If I ran my script in company 555, then I changed the company to 222 (using ttdsk2003m000). How can my script know the new current company?
get.compnr() will return the original company that my script was executed in (same as get.company() and COMPNR variable), but I need to know the current (menu browsers) company, any ideas?
Thanks in advance,
David
mark_h
19th December 2006, 21:36
About the only thing I can think of to try is something like this thread (http://www.baanboard.com/baanboard/showthread.php?t=9763) uses. You use licmon to get the bshell id and then use the bshell pid to run the process list. You might find something that reveals the company number for the browser. I can not say for sure because I have never figured out how the bshcmd command works - since I am on a UNIX server the command and format are different. Just doing a bshcmd6.1 -p <bshell_pid> does not work for me(gets nothing) and bshcmd6.1 -p -s -u 10 -w 10 bshell_pid gets all kinds of stuff and ottdskmbrowser has different companies. So you might see something like ottdskmbrowser with the current company number - again I am not sure. And I never really figured out the appropriate format of bshcmd6.1 for unix.
george7a
4th January 2007, 14:04
Hi
This code works for me:
./bshcmd6.1 -p -s -u 5 -w 5 5445
The resault was:
2 0 2 ottdskmbrowse 76123 00000060 B 200 266104
object: ottdskmbrowser
oic:
ottdskmbrowser
ottstp_stddll
ottdskmenu
So I new that the menu browser is in company 200.
The problem that only user 'root' (or the user who is using this PID) could activate this command (with good resaults) other users didn't return anything.
Example:
user 'root' can see the sessions that user 'george' is using now
user 'george' can see the sessions that user 'george' is using now
user 'bsp' can not see the sessions that user 'george' is using now
- George
david7
15th January 2007, 09:34
Thanks for the suggestion..
But I've encountered this command (bshcmd6.1) before and it wasn't stable, so I'm not sure if I can rely on it now.
Also it's a unix command but I need this solution to work for NT server too.
This solution is too complicated and long, isn't there any other way to get the menu browser's company ? How does the menu browser know his current company ? Is it a global variable ? In a file ? Table ?
david7
24th January 2007, 10:08
Any ideas ??
mark_h
24th January 2007, 16:16
Nope - sorry to say no new good ideas have popped up. To me it looks like the company number is a local variable to the menu. Can you explain why you need to do this? It might help someone else come up with a solution.
Other ideas:
(1) write your own change company code to log it in a table in a specific company.
(2) try running a function server on ttdsk2003m000 to see what company is returned. So when you change company to 123, run a session. Then go back to the menu browser and change company to 100. Then in then session running in company 123 run ttdsk2003m000 and see what company it tells you.
george7a
31st May 2007, 09:25
Just for the record... I have tried the AFS solution and it did not work.
I have also tried to activate (& sleep) ttdsk2003m000 and try to get the company using get.var but it also didn't work since it did not have the menu browser company, it had the parent company.
Best solution for now is the bshcmd command.
- George
NPRao
31st May 2007, 10:57
George,
It's a known issue - custom ttdsk2003m000 (Change company) (http://www.baanboard.com/baanboard/showthread.php?t=24801&highlight=change+company)
george7a
31st May 2007, 12:10
Hi NPRao,
I was reading the same thread before I posted my last post. I was thinking that getting the global company is easier than changing it. I believe there is a way to do so and as you say "Where there is a will, there is a way", no? ;)
Maybe an undocumented variable/function that we can use...
- George
NPRao
31st May 2007, 21:42
I wish it was that easy, I found another situation where your idea will fail:
2 0 2 ottdskmbrowse 76123 00000060 B 200 266104
You can easily write a custom program which can change company and open multiple menu browsers. Refer to the posting - menu in commandline starts ascii (http://www.baanboard.com/baanboard/showthread.php?t=10308&highlight=ttdskmbrowser)
You can easily test it by 2 statements-
change.company(200)
start.session() or activate() or any other function call for "ttdskbbrowser".
In that case you have to trace every ttdskbbrowser instance that does not have a parent process id (means it was started by the Standard Program when you logged in) and if it has a parent then it was started by your custom program.
george7a
1st June 2007, 09:00
Yes. You are right. I have noticed that. But it is not that common to start a new menu browser. Is it?
Anyway bshcmd is the best we got for now, but I am sure there is a better solution and I am sure that it WILL be found.
- George
Hitesh Shah
1st June 2007, 20:09
The solution not be the perfect solution u may be looking for. But it looks better than bshcmd route considering bshcmd may not give response if bshell is too busy doing something else.
attr.company$ has correct string value of the company which we can query ttaad100 and get the compny number .
Also each Window title has company number included (pls check for forms where company special field is not there). If u can trap this variable , u should be able to ge the current company .
And last (which u know and have probably done) to query ottdskmbrowse for each externally declared symbol (to find correct variable) using get.var function . The process id needs to be searched using pstat function .
NPRao
1st June 2007, 20:56
Hitesh,
I could not find the predefined variable attr.company$ in all the manuals that I have. I tried it in a test program and got compilation error:
pzmadmtest0(1139): Error: 'attr.company$' not declared
george7a
2nd June 2007, 15:58
Hi, I have seen a variable that contains the name of the company and I could get it using get.var from ottdskmbrowse (I am not in the office now I don't have the name of the variable here). The problem is that the name of the comapny is not a Key in the company table. Two company numbers can have the same name.
- George
Hitesh Shah
4th June 2007, 07:20
NP , For ERP Ln there should be some different variable . attr.company$ is present in Bann IV .
George , attr.company$ is present in every instance of a program . U need not query ottdskmbrowse for that purpose . Duplicate description can not be addressed for sure with company descriptions .
U can try ttfgld300.titl which contain window title with company number . U can trap the number enclosed in square brackets . Caveat - Check this on forms without special field company number .
Last - a cent percent perfect solution is to get the exact variable which holds the company in ottdskmbrowse and get the same.
george7a
4th June 2007, 08:46
Hitesh,
ttfgld300.titl does not exist in ottdskmbrowse. However I know that it does exist in every 4GL session.
I could get the name of the description of the company in the past but since it is not a unique key in the company table I can not get the company number from it, since there could be two company numbers with the same description.
- George
Hitesh Shah
4th June 2007, 09:11
Sorry It's a typing mistake . It's ttgfd300.titl and not ttfgld300.titl. It contains window title (including company number in square brackets) . If ur program is 4GL with a company number on form , then this should suffice ur requirement .
Know it may not be a complete solution for all situation. But a good workaround in a given situation .
george7a
4th June 2007, 09:18
I had tried get.var ttgfd300.titl and the result was an empty string. The return value of the get.var was 0 (error) as the variable does not exist! though I know that it did do something because the variable had "NONE" value before get.var.
Hitesh Shah
4th June 2007, 09:29
U dont need to execute any get.var for this value . It's already current in ur current program .
Does ur form have special field , company number .
george7a
4th June 2007, 09:30
But we need to get the menu browser's title! Not the current session.
Hitesh Shah
4th June 2007, 09:35
My form has special fields session code , session name and company number . So this variable has the company value in the title like
"session : session description [321]" . Does ur form have the company number in the form .
george7a
4th June 2007, 09:37
Yes it does. But we need to get the global company. The company of the menu browser and not the company of any other form/session.
Hitesh Shah
4th June 2007, 10:33
Ya I understand the technical difference . But in most cases it is the same . It may not work for example when u start the session from ttadv2100m000 .
george7a
4th June 2007, 10:37
If there is a hidden variable in ottdskmbrowse that contains the title, then that will be helpful.
I have tried all the 4GL tricks that I know but ottdskmbrowse is not a 4GL session. So it is different.
I have also tried to start a session from Maintain Sessions (ttadv2100m000), it always starts with the users default company and not the Global company.
Hitesh Shah
4th June 2007, 18:02
If there is a hidden variable in ottdskmbrowse that contains the title, then that will be helpful.
I have tried all the 4GL tricks that I know but ottdskmbrowse is not a 4GL session. So it is different..
No knowledge of the same as of yet. Have not tried it bcos i am sure u must have had put enough efforts on the same . And I am sure I will not able to give enough time for this .
I have also tried to start a session from Maintain Sessions (ttadv2100m000), it always starts with the users default company and not the Global company.
Even I mentioned the same . Before going through any workaround , one must know it's flip side also.
If none of the workaround suites ur sitation , bshcmd with its pitfalls may be the only way out for u .
george7a
5th June 2007, 09:03
I have put some efforts in this but still not all what I can. I believe there is a simpler solution than bschcmd. Every now and then I try new ideas. When the perfect one comes I will post it.
I have found some harder solutions. But if bschcmd wasn't good enough so were the others.
- George
Hitesh Shah
5th June 2007, 10:05
Agreed . Workarounds can not be replaced for 100% perfect solution .
george7a
5th June 2007, 10:48
Using the GetWindowText API (http://allapi.mentalis.org/apilist/GetWindowText.shtml) we can create an exe that gets the window title of the menu browser and from there we can get the company.
But, I still believe that there is a Baan tools solution.
- George
Hitesh Shah
8th June 2007, 11:14
Probably these too will be costly in terms of speed . Baan program will run faster than any client program for searching the window title . So the real 100% solution as u identified could be to query ottdskmbrowse and get the company number .
george7a
8th June 2007, 11:17
Yes. You are right. The win API will fail also if you had more than 2 menu browsers open.
It was just another workaround until we get to the best we can!
- George
george7a
1st November 2007, 09:19
For the record:
Since this subjuct was raised again (http://www.baanboard.com/baanboard/showthread.php?t=43630), I have checked all extern (bic_info) variables in ottdskmbrowser and none had the current company of the menu browser.
- George