Below are the
Classes created to Demonstrate
3. ESS_DemoOperationDataContract Class – (For parameter values)
4. ESS_DemoSysOperationTaskService Class – (For actual logic to execute in Batch)
{
a. Override new method
protected void new()
{
super(classStr(ESS_DemoSysOperationService), methodStr(ESS_DemoSysOperationService, update), SysOperationExecutionMode::Synchronous);
}
{
operation.startOperation();
}
ESS_DemoSysOperationDataContract contract;
}
{
maxRecId = 5648390004;
fromRecId = minRecId;
if(!batchHeader)
{
batchHeader = BatchHeader::getCurrentBatchHeader();
}
toRecId = fromRecId + 100000;
batchHeader.addRuntimeTask(controller, this.getCurrentBatchTask().RecId); // Create a runTimeTask within the current batch job
fromRecId = toRecId;
}
}
else
{
// Create a service controller to run the task
controller = new SysOperationServiceController(classStr(ESS_DemoSysOperationTaskService), methodStr(ESS_DemoSysOperationTaskService, insertRecords),SysOperationExecutionMode::Synchronous);
contract = controller.getDataContractObject();
contract.parmValues(["value01", "value02",minRecId,maxRecId]);
controller.run();
}
// If we're processing in batch, then save the batch header
if(batchHeader)
{
batchHeader.save();
}
}
{
container conValues;
}
{
conValues = _values;
return conValues;
}
public class ESS_DemoSysOperationTaskService
{
ESS_SysOperationDemoTable ess_SysOperationDemoTable;
}
{
str value01, value02;
RefRecId fromRecId, toRecId;
RecordInsertList recordInsertList = new RecordInsertList(tableNum(ESS_SysOperationDemoTable));
ess_SysOperationDemoTable.clear();
ess_SysOperationDemoTable.Field01 = 1
ess_SysOperationDemoTable.Field02 = 2;
recordInsertList.add(ess_SysOperationDemoTable);
}
recordInsertList.insertDatabase();
}
1.
ESS_DemoSysOperationController Class which
extends SysOperationServiceController – (For Batch Dialog)
2.
ESS_DemoSysOperationService Class which extends SysOperationServiceBase
– (For multitask Batch Initiation)3. ESS_DemoOperationDataContract Class – (For parameter values)
4. ESS_DemoSysOperationTaskService Class – (For actual logic to execute in Batch)
1. Create a class extends SysOperationServiceController
class ESS_DemoSysOperationController
extends
SysOperationServiceController{
}
a. Override new method
protected void new()
{
super(classStr(ESS_DemoSysOperationService), methodStr(ESS_DemoSysOperationService, update), SysOperationExecutionMode::Synchronous);
}
b. Create Construct method
server static ESS_DemoSysOperationController
construct(){
ESS_DemoSysOperationController controller;
controller = new ESS_DemoSysOperationController
();
controller.parmShowDialog(true);
// Actually the default value
controller.parmShowProgressForm(false);
return controller;
}
c. Create main method
static void main(Args args)
{
ESS_DemoSysOperationController
operation;
operation = new ESS_DemoSysOperationController
();operation.startOperation();
}
2. Create a class extends SysOperationServiceBase
class ESS_DemoSysOperationService
extends SysOperationServiceBase
{
BatchHeader batchHeader;
SysOperationServiceController controller;ESS_DemoSysOperationDataContract contract;
}
a. Create update method
[SysEntryPointAttribute]
public void update(){
RefRecId minRecId, maxRecId, fromRecId, toRecId;
minRecId = 5637775244;maxRecId = 5648390004;
fromRecId = minRecId;
if(this.isExecutingInBatch())
{if(!batchHeader)
{
batchHeader = BatchHeader::getCurrentBatchHeader();
}
while
(toRecId < maxRecId)
{toRecId = fromRecId + 100000;
// Create a service controller to run the
task
controller = new
SysOperationServiceController(classStr(ESS_DemoSysOperationTaskService),
methodStr(ESS_DemoSysOperationTaskService,
insertRecords),SysOperationExecutionMode::Synchronous);
contract = controller.getDataContractObject();
contract.parmValues(["value01",
"value02",fromRecId,toRecId]);batchHeader.addRuntimeTask(controller, this.getCurrentBatchTask().RecId); // Create a runTimeTask within the current batch job
fromRecId = toRecId;
}
}
else
{
// Create a service controller to run the task
controller = new SysOperationServiceController(classStr(ESS_DemoSysOperationTaskService), methodStr(ESS_DemoSysOperationTaskService, insertRecords),SysOperationExecutionMode::Synchronous);
contract = controller.getDataContractObject();
contract.parmValues(["value01", "value02",minRecId,maxRecId]);
controller.run();
}
// If we're processing in batch, then save the batch header
if(batchHeader)
{
batchHeader.save();
}
}
3. Create a Class ESS_DemoSysOperationDataContract
[DataContractAttribute]
public class ESS_DemoSysOperationDataContract{
container conValues;
}
a. Create parmValues method
[DataMemberAttribute]
public container parmValues(container _values = conValues){
conValues = _values;
return conValues;
}
4. Create a Class ESS_DemoSysOperationTaskService
public class ESS_DemoSysOperationTaskService
{
ESS_SysOperationDemoTable ess_SysOperationDemoTable;
}
a. Create insertRecords method
[SysEntryPointAttribute]
public insertRecords(ESS_DemoSysOperationDataContract
_contract){
str value01, value02;
RefRecId fromRecId, toRecId;
RecordInsertList recordInsertList = new RecordInsertList(tableNum(ESS_SysOperationDemoTable));
[value01,
value02, fromRecId, toRecId] = _contract.parmValues();
While (condition)
{ess_SysOperationDemoTable.clear();
ess_SysOperationDemoTable.Field01 = 1
ess_SysOperationDemoTable.Field02 = 2;
recordInsertList.add(ess_SysOperationDemoTable);
}
recordInsertList.insertDatabase();
}