mardi 14 décembre 2010

How to change company from X++

The changeCompany statement is used to alter the database settings to another (separate) company. The syntax of the statement is:
changeCompany ( Expression ) Statement
Here is the code

static void main()
{
    CustTable custTable;
    ;
    // Assume that you are running in company 'aaa'.
    changeCompany('bbb') // Default company is now 'bbb'.
    {
        custTable = null;
        while select custTable
        {
            // custTable is now selected in company 'bbb'.
        }
    }
    // Default company is again set back to 'aaa'.

    changeCompany('ccc') // Default company is now 'ccc'.
    {   
        // Clear custTable to let the select work
        // on the new default company.
        custTable = null;
   
        while select custTable
        {
            // custTable is now selected in company 'ccc'.
        }
    }
    // Default company is again 'aaa'.
}

Happy Daxing !

1 commentaire:

  1. table = null;
    worked in my case.
    If you are using changecompany(''); in a loop, table = null; should be used.

    RépondreSupprimer