Try CHANGECOMPANY function. this function is used to redirect references to table data from one company to another.
Example
This example shows how to use the CHANGECOMPANY function.
"G/L Account".CHANGECOMPANY('New Company');
"G/L Account".GET('1000');
"G/L Account".CALCFIELDS(Balance);// Calculates the balance
// for account no. 1000 in
// 'New Company'
"G/L Entry".CHANGECOMPANY('New Company');
"G/L Entry".SETCURRENTKEY("No.",LedgerEntry.Date);
"G/L Entry".SETRANGE("No.",'1000');
"G/L Entry".SETRANGE(Date,010196D,013196D);
"G/L Entry".CALCSUMS(NetAmount); // Sums NetAmount from
// all G/L entries on
// account no. 1000 within
// the specified range,
// for 'New Company'
"G/L Entry".RESET;
"G/L Entry".FIND('+'); // Finds the largest "No."
// in the G/L Entry table in
// 'New Company'
"G/L Entry".DELETE; // Deletes this entry in
// 'New Company'
This example shows that once the CHANGECOMPANY function has been called, all future references to the G/L Account and G/L Entry tables will refer to the table data in New Company.
Comments
Try CHANGECOMPANY function. this function is used to redirect references to table data from one company to another.
Example
This example shows how to use the CHANGECOMPANY function.
"G/L Account".CHANGECOMPANY('New Company');
"G/L Account".GET('1000');
"G/L Account".CALCFIELDS(Balance);// Calculates the balance
// for account no. 1000 in
// 'New Company'
"G/L Entry".CHANGECOMPANY('New Company');
"G/L Entry".SETCURRENTKEY("No.",LedgerEntry.Date);
"G/L Entry".SETRANGE("No.",'1000');
"G/L Entry".SETRANGE(Date,010196D,013196D);
"G/L Entry".CALCSUMS(NetAmount); // Sums NetAmount from
// all G/L entries on
// account no. 1000 within
// the specified range,
// for 'New Company'
"G/L Entry".RESET;
"G/L Entry".FIND('+'); // Finds the largest "No."
// in the G/L Entry table in
// 'New Company'
"G/L Entry".DELETE; // Deletes this entry in
// 'New Company'
This example shows that once the CHANGECOMPANY function has been called, all future references to the G/L Account and G/L Entry tables will refer to the table data in New Company.
Do we have to use Table directly or can we use record variable of the table instead ?
like using record Variable RecG/LAccount of G/L Entry Table
RecG/LAccount.CHANGECOMPANY('New Company');
RecG/LAccount.GET('1000');
RecG/LAccount.CALCFIELDS(Balance);// Calculates the balance
Regards
Renjita