Hi,
{
BatchHeader batchHeader; BatchInfo localBatchInfo; YourRunBaseBatchClass yourRunBaseBatchClass; SysRecurrenceData sysRecurrenceData = SysRecurrence::defaultRecurrence(); ;
yourRunBaseBatchClass = YourRunBaseBatchClass::construct();
// Retry 3-times
sysRecurrenceData = SysRecurrence::setRecurrenceEndAfter( sysRecurrenceData, 3);
//Retry 1-min
sysRecurrenceData = SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Minute, 1); localBatchInfo = yourRunBaseBatchClass.batchinfo(); localBatchInfo.parmGroupId("YourBatchGroupId"); batchHeader = batchHeader::construct(); batchHeader.addTask(yourRunBaseBatchClass); batchHeader.parmRecurrenceData(sysRecurrenceData); batchHeader.save(); }
Happy DAXing...
Case-1:
static void TID_ExecuteBatchJobDistribution(Args _args) { BatchHeader header; SysRecurrenceData sysRecurrenceData; Batch batch; BatchJob batchJob; RetailConnScheduleRunner _RetailConnScheduleRunner; // Class extends RunBaseBatch BatchInfo processBatchInfo; BatchRetries noOfRetriesOnFailure = 4; ; // Setup the RunBaseBatch Job header = BatchHeader::construct(); _RetailConnScheduleRunner = new RetailConnScheduleRunner(); processBatchInfo = _RetailConnScheduleRunner.batchInfo(); processBatchInfo.parmRetriesOnFailure(noOfRetriesOnFailure); processBatchInfo.parmCaption(_RetailConnSchedule.Name); // Description Batch Job processBatchInfo.parmGroupId('RTL'); // Batch Gorup processBatchInfo.parmBatchExecute(NoYes::Yes); header.addTask(_RetailConnScheduleRunner); // Set the recurrence data sysRecurrenceData = SysRecurrence::defaultRecurrence(); SysRecurrence::setRecurrenceStartDateTime(sysRecurrenceData, DateTimeUtil::addSeconds(DateTimeUtil::utcNow(), 20)); // Set range of recurrence SysRecurrence::setRecurrenceNoEnd(sysRecurrenceData); SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Minute); // Set reccurence pattern header.parmRecurrenceData(sysRecurrenceData); // Set the batch alert configurations header.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::Yes); header.save(); // Update the frequency to run the job to every two minutes ttsbegin; select forupdate batchJob join batch where batchJob.RecId == batch.BatchJobId && batch.ClassNumber == classnum(RetailConnScheduleRunner); sysRecurrenceData = batchJob.RecurrenceData; sysRecurrenceData = conpoke(sysRecurrenceData, 8, [10]); batchJob.RecurrenceData = sysRecurrenceData; batchJob.update(); ttscommit; }Case-2:
public static void scheduleBatch(){
BatchHeader batchHeader; BatchInfo localBatchInfo; YourRunBaseBatchClass yourRunBaseBatchClass; SysRecurrenceData sysRecurrenceData = SysRecurrence::defaultRecurrence(); ;
yourRunBaseBatchClass = YourRunBaseBatchClass::construct();
// Retry 3-times
sysRecurrenceData = SysRecurrence::setRecurrenceEndAfter( sysRecurrenceData, 3);
//Retry 1-min
sysRecurrenceData = SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Minute, 1); localBatchInfo = yourRunBaseBatchClass.batchinfo(); localBatchInfo.parmGroupId("YourBatchGroupId"); batchHeader = batchHeader::construct(); batchHeader.addTask(yourRunBaseBatchClass); batchHeader.parmRecurrenceData(sysRecurrenceData); batchHeader.save(); }
Happy DAXing...