Showing posts with label Batch Jobs. Show all posts
Showing posts with label Batch Jobs. Show all posts
Batch job Execution for ALL Companies
Batch job Execution for ALL Companies
void run()
{
while select crossCompany purchTable
{
changeCompany(purchTable.DataAreaId)
{
// todo your logic
}
}
}
Batch Job Schedule X++ D365FO
Batch Job Schedule D365FO
With the following X++ sample code you can schedule a Batch job.
Sample Code
static void batchJobSchedule(Args _args)
{
BatchHeader objBatchheader;
SysRecurrenceData sysRecurrenceData;
Batch batch;
BatchJob batchJob;
RetailCDXScheduleRunner objRetailSchedule;
BatchInfo objBatchInfo;
BatchRetries noOfRetriesOnFailure = 0;
;
// Setup the RunBaseBatch Job
objBatchheader = Batchheader::construct();
objRetailSchedule = new RetailCDXScheduleRunner();
objBatchInfo =
objRetailSchedule.batchInfo();
objBatchInfo.parmRetriesOnFailure(noOfRetriesOnFailure);
objBatchInfo.parmCaption("Description
should be here"); // Description Batch Job
objBatchInfo.parmGroupId('YourBatchGroup'); // Batch Gorup
objBatchInfo.parmBatchExecute(NoYes::Yes);
objBatchheader.addTask(objRetailSchedule);
// 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
objBatchheader.parmRecurrenceData(sysRecurrenceData);
// Set the batch alert configurations
objBatchheader.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::Yes);
objBatchheader.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;
}
Batch Job D365FO & AX 2012
Batch Job D365FO & AX 2012
Following the below steps, You can create the batch job in simple steps.
First Create a Class and extends it with the RunBaseBatch class
Then override the description method and return the job name. it will appear on job dialog.
Now override the run method and write your logic. in my case i was updating the status from 0 to 1 in my custom table
Now override the main method and run your code like the below image
Now Run the class by right click and select open a dialog will appear like the below image.
Subscribe to:
Posts (Atom)
Virtual Fields Vs Computed Fields
Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...
-
D365FO Interview Questions & Answers What is Microsoft Dynamics AX? Answer: Link What is the difference between Microsoft Dynamics AX...
-
Multi-threaded batch job Normally, when we schedule our "Run Base Batch" class as a batch job, it will create a single task. Wh...
-
Release Product Using X++ You can use the below code to release the product to any legal entity using X++ or a custom batch job. Sample Co...