Skip to main content

Develop batch job through SysOperationServiceBase class

 Friends,

                     Microsoft Dynamics D365 finance and operations have a strong batch job functionality that runs on periodic time as per user requirements. I have created one batch job that will export invent table data from the system to an excel file. Go through the given steps and get this functionality.

Step 1 : Create Contract Class SPInventTableDataContractBatch

[DataContractAttribute]
class SPInventTableDataContractBatch
{
    ItemType          itemType;
}

Step 2 : Add parmItemType() method to SPInventTableDataContractBatch class and write this
              logic,
[DataMemberAttribute]
public ItemType parmItemType(ItemType  _itemType = itemType)
{
    itemType  = _itemType;
    return itemType;
}

Step 3 : Create ServiceClass SPInventTableBatchService

class SPInventTableBatchService extends SysOperationServiceBase
{

}

Step 4 : Add processData() method to SPInventTableBatchService class and write this      
              logic,

[SysEntryPointAttribute(true)]
public str processData(SPInventTableDataContractBatch _dataContract)
{
    //Write the business logic here

    return "Completed";
}
Step 5 : create SPInventTableBatchController and write this      
              logic,
class SPInventTableBatchController extends SysOperationServiceController
{
}
Step 6 : Add defaultCaption() method to SPInventTableBatchController class and write this      
              logic,
protected ClassDescription defaultCaption()
{
    return "Batch job by SysOperationServiceBase class";
}

Step 7 : Add new() method to SPInventTableBatchController class and write this      
              logic,

public void new()
{
    super(classStr(SPInventTableBatchService), methodStr(SPInventTableBatchService, processData), SysOperationExecutionMode::Synchronous);
}

Step 8 : Add SPInventTableBatchController () construct to
              SPInventTableBatchController class and write this logic,

public static SPInventTableBatchController construct()
{
    SPInventTableBatchController   controller;

    controller  = new SPInventTableBatchController();
    controller.parmShowDialog(true);
    controller.parmShowProgressForm(false);

    return controller;

}

Step 9 : Add main() method to  SPInventTableBatchController class and write this logic,
public static void main(Args _args)
{
    SPInventTableBatchController       controller;

    controller  = SPInventTableBatchController::construct();
    controller.startOperation();
}

Comments