Gwehles
22nd February 2007, 15:05
Hi all,
Is there a way to change the current VRC in a script?
I have on one server two companies, 200 and 300 which are in a different VRC. So when i execute the function switch.to.company(300) it returns me that this company is in a diffrent VRC.
I only need to read datas for creating a text file, so no need tu update!
Thanks for any suggestions.

en@frrom
22nd February 2007, 15:26
I have never tried to do this during runtime of a session, but theoretically you can do that easily. Since your Baan version details are not filled in, I do not know what version you are on. Talking from my Baan 5 environment:

The current package vrc per user is stored in table ttadv040 in company 000. The package vrc can be changed through session ttadv0140m000. So you could either write an api (afs) which calls ttadv0140m000 and changes the package vrc (-> recommended), or you could program to change the package vrc directly in table ttadv040. I am not sure, but I think there are no other actions taken by session ttadv0140m000 except for changing table ttadv040.

Of course after reading your data, don't forget to change it all back again before continuing your program...

Let us know the results...


Regards,
Eli Nager

Gwehles
22nd February 2007, 16:35
Hi,
this could work, never thaught on that possibility.
The only problem that i could imagine is that even if i change the VRC for my user with API, my datadictionary hasen't changed. Or doesn't the DD have an influence there.
Thanks for this suggestion, i'l try it tomorow!

en@frrom
22nd February 2007, 16:40
Like I said I think all the regular session does is changing the table, but you should try it... About DD: this I can tell you, is not needed, so no problem there. The changes are effective without updating/converting dd

Regards,
Eli Nager

NPRao
22nd February 2007, 22:35
Gwehles,
Is there a way to change the current VRC in a script?
I have on one server two companies, 200 and 300 which are in a different VRC. So when i execute the function switch.to.company(300) it returns me that this company is in a diffrent VRC.
I only need to read datas for creating a text file, so no need tu update!
Thanks for any suggestions.
I think you are missing the basic point here -
switch.to.company()
--------------------------------------------------------------------------------
Syntax
long switch.to.company( long new_compnr )
Description
This switches to another company and sets the read-only variable COMPNR to the specified company number. It performs several checks before switching company and switches company only if the checks are successful. For example, it checks if the user is authorized to change to the new company, it checks if the package combination linked to the old company contains the same package VRC's as the package combination linked to the new company, and it checks if the old and new companies have the same first day of the week.
Notes
compnr.check() and switch.to.company() perform similar functions, but switch.to.company() performs additional checks. So switch.to.company() makes heavier demands on system resources.
Be aware that when there is a switch to another company, the user's first day of the week does not change, even if the new company has a different first day of the week. switch.to.company() returns an error value if the old and new companies have different first days of the week. compnr.check() does not.
Super users are authorized for all company numbers. They always have authority to switch to a different company number. In addition, super users can also use the data dictionary to authorize other users for particular company numbers.

Return values
1 Success.

-1 Company not available.

-2 No permission to change to this company.

-3 Package combination does not correspond with new company number.

-4 First day of the week does not correspond to first day of the week of original company.

Context 3GL library function.
Companies are linked to package combinations and not VRCs. We have different package combinations with derived VRCs and we can switch companies because there are no DD differences (tables, domains).
Your alternative option is to use -
compnr.check()
--------------------------------------------------------------------------------
Syntax
boolean compnr.check( long new_compnr )
Description
This switches to another company and sets the read-only variable COMPNR to the specified company number. It checks whether the user is authorized for the new company, and switches company only if so.

Notes
compnr.check() and switch.to.company() perform similar functions, but switch.to.company() performs additional checks. So switch.to.company() makes heavier demands on system resources.

Be aware that when there is a switch to another company, the user's first day of the week does not change, even if the new company has a different first day of the week. switch.to.company() returns an error value if the old and new companies have different first days of the week. compnr.check() does not.

Super users are authorized for all company numbers. They always have authority to switch to a different company number. In addition, super users can use the data dictionary to authorize other users for particular company numbers.

Return values
true User is authorized; Company switched.

false User is not authorized; Company not switched.

Context Bshell function.