Jan 6, 2012

Change company from the current company in X++ code

This example will helps you to change the company from current company in x++ code.


static void main()
{
CustTable custTable;
;

//Assume that you are running in company 'DAT'.
changeCompany('DAT1') //Default company is now 'DAT1'.
{
custTable = null;
while select custTable
{
//custTable is now selected in company 'DAT1'.
}
}

//Default company is again set back to 'DAT'.

changeCompany('DAT2') //Default company is now 'DAT2'.
{
//Clear custTable to let the select work
//on the new default company.
custTable = null;

while select custTable
{
//custTable is now selected in company 'DAT2'.
}
}

//Default company is again 'DAT'.

}

No comments: