crossCompany Keyword on the X++ Select Statement
The following code example populates a table buffer with all the BankAccountTable rows that have a dataAreaId of either cm1 or cm2. This example assumes that the user has authority to access data for these two companies. The first two dataAreaId values that are found will be printed.
The following code example populates a table buffer with all the BankAccountTable rows that have a dataAreaId of either cm1 or cm2. This example assumes that the user has authority to access data for these two companies. The first two dataAreaId values that are found will be printed.
BankAccountTable tabBAT; // saveDataPerCompany == true.
container conCompanies = [ 'cm1', 'cm2' ];
str sCompanyPrevious =" ";
int iCountCompanies = 0;
;
while select crossCompany : conCompanies * from tabBAT order by dataAreaId
{
if ( sCompanyPrevious != tabBAT .dataAreaId )
{
print( tabBAT .dataAreaId + " = tabBAT .dataAreaId" );
iCountCompanies++;
if ( iCountCompanies >= 2 )
{
break;
}
sCompanyPrevious = tabBAT .dataAreaId;
}
}
pause;
return;