Initially test in a job to know whether you are getting the data or not.
You need to reset the table buffer while using Changecompany() otherwise result will be too heavy as the buffer contains old data as well.
while select contractCompany
{
nameOfCompany = null; // reset the table buffer
if (contractCompany.dataAreaId == '003')
{
changecompany(contractCompany.CompanyCode)
{
nameOfCompany = CompanyInfo::name();
}
}
if (contractCompany.dataAreaId == '014')
{
changecompany(contractCompany.CompanyCode)
{
nameOfCompany = CompanyInfo::name();
}
}
info(nameOfCompany.FieldName);// display the msg to test
}