我有两个全球课程。在 CreateAndModify 类中,我有一个执行函数,它有一个 for 循环,它调用我的另一个类的 processRecord 方法,即 CreateAndModifyProcessor。问题是在我的第一堂课中声明了一个列表集合,我无法在第二堂课中访问。有没有办法做到这一点,这样做甚至是一个好主意吗?
global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{
global void execute(
Database.BatchableContext BC,
List<sObject> listObj){
list <Account__c> inAcc = new list<Account__c>();
for (sObject lo : listObj){
processor.processRecord(lo);
}
insert inAcc; // The list object which i
// am modifying in the processRecord function has to be added to
// the database. So, is it a good idea to add/populate the
// in other function of other class
}
global class CreateAndModifyProcessor {
global void processRecord(sObject listObj){
Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)listObj;
Account__c tempAcc = new Account__c();
inAcc.add(tempAcc); // This line throws an error
}
}