Overview
RunBase framework provides a common software platform for data manipulation in Microsoft Dynamics AX. It provides a standardized pathway to create batch jobs and periodic processes.
RunBase framework can be used to run a process periodically or to manipulate some data over a period of time.
Using RunBase framework has the following advantages:
- All future updates are integrated automatically
- Common layout of dialog
- Remembering the user selections from the last run
- Easy to implement
To implement RunBase framework, extend a class with RunBaseBatch.
Pre-requisites
- Microsoft Dynamics AX 2012
- Batch server must be configured
Important Methods
Run
Run is the central method of the RunBase framework and is where all business logic is written. All data manipulation statements are placed in this method.Description
Description is a static method that returns a descriptive name of a batch job. This name is then shown as a caption on the batch job dialog to identify the specific job in batch queue.Main
Main is a static method which provides the entry point for a batch job. This method calls the prompt method, which calls the RunBase dialog, and run method which processes the batch job.
Scenario
As part of this tutorial, the RunBase class will mark all customers on-hold who have exceeded their credit limit .
Steps
- First create a new class. Open AOT àClasses
- Right
click on Classes, select New Class, and create a new RunBaseDemo class - Open the class declaration by right clicking on the RunBaseDemo class and selecting
View Code - Write the following code:
- Add a new method and name it as description. Write the following code in the method:client server static ClassDescription description()
{
return “Mark customers on-hold”;
} - Add a new method and name it as main. Write the following code in the method:static void main(Args _args)
{
RunBaseDemo objClass = new RunBaseDemo();//prompt for runbase framework dialog
if (objClass.prompt())
{
//run the process
objClass.run();
}
} - Override the run method and write the following code:public void run()
{
CustTable custTable;//start transaction
ttsbegin;try
{
//select all customers
while select forUpdate * from custTable
{//if credit limit is reached, placed on-hold
if(custTable.CreditMax && custTable.balanceMST() > custTable.CreditMax)
{
custTable.Blocked = CustVendorBlocked::Invoice;
custTable.update();
}
}//end transaction
ttsCommit;
}
catch
{
//throw error of failure
error(“Process failed”);
}
} - Run the job by right clicking on the RunBaseDemo class and select Open. Alternatively, the job can also be called from a menu item
- The RunBase framework dialog will open
- There are two ways to run the batch job, only once and periodically
- If once, click OK. Use this
option if you want to run the job just this time - If periodically, schedule the batch job. Use this option if you want to run the job periodically. Follow the following steps to schedule the batch job
Check the Batch processing box- Select the respective batch group from the Batch group drop down
- Click on the Recurrence button
- In the Recurrence dialog, set an appropriate schedule and click OK
- Click OK to schedule. It will now run the job according to the inputted schedule
- Batch job history can be viewed from System administration à Inquiries à Batch jobs à Batch job history
class RunBaseDemo extendsRunBaseBatch
{
{
}
This post is very helpful for Microsoft Dynamics Consultant. I really appreciate your effort for sharing this kind of information. In future, If you'll looking for a job in Microsoft Dynamics AX, Then you'll should visit at Microsoft Dynamics AX Consultant
ReplyDelete