David Singleton:
Firstly, whilst it seems simple, it is not a good idea to make the master records (Cust, item etc) as common to all companies, it just causes too many problems. Better is to write code that syncs them between all the companies, which is a really simple bit of code.
Beaver:
I must agree to David: Setting Customer to DataPerCompany=No seems to be simple, but it surely is not.
In order to have consistent data, you must also set all the tables to DataPerCompany=No, to which fields in the customer table refer to. An example would be the Gen. Bus. Posting Group table.
If you do not do that and you set up different Posting Groups in the companies, the validation of that field in table customer will fail.
That need to make many more tables valid for all companies can lead to serious problems. Take the Payment Terms table. This is valid for customers AND vendors. If you make customers DataPerCompany=No than the Payment Terms table will have to be DataPerCompany=No as well. Then you cannot set up different payment terms for your vendors per company which you still might want to.
Synchronizing is generally the better way to do it.
I didn't say it is easy and without any concerns.
Here's also a post, where I described a bit more about DataPerCompany and what you should be aware of: http://www.mibuso.com/forum/viewtopic.php?t=2524
I tried using CHANGECOMPANY function ,,I am not able to get the solution rather i am not approaching the solution correctly.Can any one please give me some sample code regarding CHANGECOPANY for inserting one record from one company to all the companies in the database.
create a global variable, e.g. Comp, from type record and Subtype 2000000006 "Company". In this table are all Compynies of your Database. The following example shows how one Item is inserted in all Companies.
Create a funcion with Parameter Item of Type Record an Subtype 27 Item. This Record will be inserted in all other Comanies.
Comp.FIND(-');
REPEAT
IF Comp.Name <> COMPANYNAME THEN BEGIN
Item2.CHANGECOMPANY(Comp.Name);
Item2.COPY(Item);
If not Item2.insert THEN
Item2.MODIFY;
END;
UNTIL Comp.NEXT = 0;
Attention: This Routine does NOT validate any field in the other Companies!!! If you want to do this you have to assign every single value from teim to item2 and validate the fields. But remember: The tables (global and local records) which were refered to in the Validate-triggers belong to the active company!!! You have to use CHANGECOMPANY for this tables, too!!! To find all neccessary tables is a hard work. But this is your only way to use this function!
Comments
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
otherwise you shouldcreate some code using CHANGECOMPANY function...
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
David Singleton:
Firstly, whilst it seems simple, it is not a good idea to make the master records (Cust, item etc) as common to all companies, it just causes too many problems. Better is to write code that syncs them between all the companies, which is a really simple bit of code.
Beaver:
I must agree to David: Setting Customer to DataPerCompany=No seems to be simple, but it surely is not.
In order to have consistent data, you must also set all the tables to DataPerCompany=No, to which fields in the customer table refer to. An example would be the Gen. Bus. Posting Group table.
If you do not do that and you set up different Posting Groups in the companies, the validation of that field in table customer will fail.
That need to make many more tables valid for all companies can lead to serious problems. Take the Payment Terms table. This is valid for customers AND vendors. If you make customers DataPerCompany=No than the Payment Terms table will have to be DataPerCompany=No as well. Then you cannot set up different payment terms for your vendors per company which you still might want to.
Synchronizing is generally the better way to do it.
Here's also a post, where I described a bit more about DataPerCompany and what you should be aware of:
http://www.mibuso.com/forum/viewtopic.php?t=2524
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Thanks
e-Brahma
Create a funcion with Parameter Item of Type Record an Subtype 27 Item. This Record will be inserted in all other Comanies.
Attention: This Routine does NOT validate any field in the other Companies!!! If you want to do this you have to assign every single value from teim to item2 and validate the fields. But remember: The tables (global and local records) which were refered to in the Validate-triggers belong to the active company!!! You have to use CHANGECOMPANY for this tables, too!!! To find all neccessary tables is a hard work. But this is your only way to use this function!
Hope this helps.
Regards,
Frank
Thanxs