Friday 13 July 2018

Create batch job using x++

Today I will be discussing about how to create batch job through x++.  Before going in code lets discuss what are batch jobs.

Batch job : It is group of tasks that submitted to an AOS for automatic processing. These tasks can run sequentially or simultaneously. Additionally, we can create dependencies between one task and another which means that we can setup a different sequence of tasks, depending on whether an earlier task successfully processed or fails.

You can create batch jobs either manually or by code. But here I will be showing a code snippet for batch job creation through x++. I have created a job just for demonstration which will create batch jobs. .













Note:  TestDemo class is my custom class that extends runBaseBatch. It will have its own run method which will contain business logic.
.
public class TestDemo extends RunBaseBatch
{}

Batch job Id :  It will be recid of current batch job.
SysRecurrence : This sysRecurrence class will be used to set recurrence of job. You may set it to default recurrence or as per your requirements
SysRecurrenceUnit : This method will be used to set count for retry. It need parameters and i have choosen 1 minute for retry.
Batchinfo : It will give batch information.
AddTask   : It will create /add task in batch job.Two parameters are required in this method one is  yourclassname and another is batchjobid.
parmCaption : It will be used for setting caption of job.

Tip : You can use this code for creating a single batch job with single task and as well as multiple task. It depend upon your requirements whether you want multiple task in parallel for instance dependency task.

For dependency task use this method : batcheader.addDependency(batchtask2, batchtask1, batchDependencyStatus::FinishedOrError);




No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Connect and upload in azure blob with azure key vault using x++

 Today, I will be sharing details about file upload in azure blob using azure vault that includes pre requisite and code snippet used to it....