Hi,
I'm trying to access a class variable in run() method of a Class which extends RunBaseBatch. I'm trying to create a BatchJob with multiple tasks and each task must have a unique value in a class variable to be separately identifiable in further code.
Here's my Class:
class ParallelBatchTest extends RunBaseBatch
{
#define.CurrentVersion(1)
int batchNo;
}
public void new()
{
super();
}
public container pack()
{
return conNull();
}
private void parmBatchNo(int _batchNo)
{
BatchNo = _batchNo;
}
void run()
{
batchtest batchtest;
batchtest.BatchNo=BatchNo; //BatchNo is not accessible at runtime.
batchtest.insert();
}
public boolean unpack(container packedClass)
{
return true;
}
public static ParallelBatchTest construct(int _batchNo)
{
ParallelBatchTest c;
c = new ParallelBatchTest();
c.parmBatchNo(_batchNo);
return c;
}
Job to schedule BatchJob with multiple tasks:
static void batchTest(Args _args)
{
BatchHeader batchHeader;
ParallelBatchTest parallelBatchTest;
BatchInfo batchInfo;
int i,taskCount=5;
batchHeader = BatchHeader::construct();
batchHeader.parmCaption(strFmt('Batch JOB 1'));
for (i=1; i <= taskCount; i++)
{
parallelBatchTest = ParallelBatchTest::construct(i);
batchInfo = parallelBatchTest.batchInfo();
BatchInfo.parmCaption('BatchTest'+int2str(i));
batchHeader.addTask(parallelBatchTest);
}
batchHeader.save();
info('Done');
}
Result after Batch Job completes:

Issue:
The BatchNo columns should have been 1,2,3,4,5 instead of 0,0,0,0,0. Which means the class variable BatchNo was not accessible in the run() method.
I have run the Incremental CIL. So the class is fully compiled to CIL.
How can I correct this?
*This post is locked for comments
I have the same question (0)