static void addSysOperationBatch(Args _args)
{
#define.recurrenceStartTime('11:00')
#define.recurrenceInterval(1)
#define.noOfRetriesOnFailure(2)
BatchHeader batchHeader;
BatchInfo batchInfo;
SysRecurrenceData sysRecurrenceData;
utcDateTime batchStartTime;
Batch batch;
PurchReqAuthorizationBatchService PurchReqAuthorizationBatchService;
PurchReqAuthorizationTaskDataContract PurchReqAuthorizationTaskDataContract;
SysOperationServiceController PurchReqAuthorizationBatchServiceController;
;
select firstOnly RecId from batch
where batch.ClassNumber == classNum(PurchReqAuthorizationBatchService) &&
batch.Company == curext() &&
batch.DataPartition == getcurrentpartition();
if (!batch.RecId)
{
PurchReqAuthorizationBatchServiceController = new SysOperationServiceController(classStr(PurchReqAuthorizationBatchService), methodStr(PurchReqAuthorizationBatchService, process), SysOperationExecutionMode::Synchronous);
PurchReqAuthorizationTaskDataContract = PurchReqAuthorizationBatchServiceController.getDataContractObject(classStr(PurchReqAuthorizationTaskDataContract));
batchInfo = PurchReqAuthorizationBatchServiceController.batchInfo();
batchInfo.parmRetriesOnFailure(#noOfRetriesOnFailure);
// Create the batch job
batchHeader = BatchHeader::construct();
batchHeader.addTask(PurchReqAuthorizationBatchServiceController);
batchStartTime = DateTimeUtil::newDateTime(systemDateGet(), str2time(#recurrenceStartTime), DateTimeUtil::getUserPreferredTimeZone());
// Set the recurrence data
sysRecurrenceData = SysRecurrence::defaultRecurrence();
sysRecurrenceData = SysRecurrence::setRecurrenceStartDateTime(sysRecurrenceData, batchStartTime);
sysRecurrenceData = SysRecurrence::setRecurrenceNoEnd(sysRecurrenceData);
sysRecurrenceData = SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Day, #recurrenceInterval);
batchHeader.parmRecurrenceData(sysRecurrenceData);
// Set the batch alert configurations
batchHeader.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::Yes);
batchHeader.parmStartDateTime(batchStartTime);
// Save the batch job
batchHeader.save();
}
}
{
#define.recurrenceStartTime('11:00')
#define.recurrenceInterval(1)
#define.noOfRetriesOnFailure(2)
BatchHeader batchHeader;
BatchInfo batchInfo;
SysRecurrenceData sysRecurrenceData;
utcDateTime batchStartTime;
Batch batch;
PurchReqAuthorizationBatchService PurchReqAuthorizationBatchService;
PurchReqAuthorizationTaskDataContract PurchReqAuthorizationTaskDataContract;
SysOperationServiceController PurchReqAuthorizationBatchServiceController;
;
select firstOnly RecId from batch
where batch.ClassNumber == classNum(PurchReqAuthorizationBatchService) &&
batch.Company == curext() &&
batch.DataPartition == getcurrentpartition();
if (!batch.RecId)
{
PurchReqAuthorizationBatchServiceController = new SysOperationServiceController(classStr(PurchReqAuthorizationBatchService), methodStr(PurchReqAuthorizationBatchService, process), SysOperationExecutionMode::Synchronous);
PurchReqAuthorizationTaskDataContract = PurchReqAuthorizationBatchServiceController.getDataContractObject(classStr(PurchReqAuthorizationTaskDataContract));
batchInfo = PurchReqAuthorizationBatchServiceController.batchInfo();
batchInfo.parmRetriesOnFailure(#noOfRetriesOnFailure);
// Create the batch job
batchHeader = BatchHeader::construct();
batchHeader.addTask(PurchReqAuthorizationBatchServiceController);
batchStartTime = DateTimeUtil::newDateTime(systemDateGet(), str2time(#recurrenceStartTime), DateTimeUtil::getUserPreferredTimeZone());
// Set the recurrence data
sysRecurrenceData = SysRecurrence::defaultRecurrence();
sysRecurrenceData = SysRecurrence::setRecurrenceStartDateTime(sysRecurrenceData, batchStartTime);
sysRecurrenceData = SysRecurrence::setRecurrenceNoEnd(sysRecurrenceData);
sysRecurrenceData = SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Day, #recurrenceInterval);
batchHeader.parmRecurrenceData(sysRecurrenceData);
// Set the batch alert configurations
batchHeader.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::Yes);
batchHeader.parmStartDateTime(batchStartTime);
// Save the batch job
batchHeader.save();
}
}