static void crossCompanyUpdate(Args _args) { CustTable custTable; CustGroup custGroup; PaymTermId oldPaymTermId = 'Net10', newPaymTermId = 'Net11'; ttsBegin; // find all companies with oldPaymTermId while select crossCompany custGroup group by custGroup.dataAreaId where custGroup.PaymTermId == oldPaymTermId { changeCompany(custGroup.dataAreaId) { // disable update method custTable.skipDataMethods(true); // set newPaymTermId update_recordSet crossCompany custTable setting PaymTermId = newPaymTermId where custTable.PaymTermId == oldPaymTermId; } } ttsCommit; } |
Solution
There is no compile or runtime error, but records are updated only in one company. Table variable must be set to
null
within changeCompany
statement, marked in orange below:static void crossCompanyUpdate(Args _args) { CustTable custTable; CustGroup custGroup; PaymTermId oldPaymTermId = 'Net10', newPaymTermId = 'Net11'; ttsBegin; // find all companies with oldPaymTermId while select crossCompany custGroup group by custGroup.dataAreaId where custGroup.PaymTermId == oldPaymTermId { changeCompany(custGroup.dataAreaId) { custTable = null; // disable update method custTable.skipDataMethods(true); // set newPaymTermId update_recordSet crossCompany custTable setting PaymTermId = newPaymTermId where custTable.PaymTermId == oldPaymTermId; } } ttsCommit; } |