Share This Post

Dynamics AX Updates

Dynamics AX RunBase Framework

Dynamics AX RunBase framework Overview

Dynamics AX RunBase framework provides a common software platform for data manipulation in Microsoft Dynamics. It gives a standardized pathway to create batch jobs and periodic processes.

Dynamics AX RunBase framework can be used to run a process periodically or to manipulate some data over a period of time.

Using Dynamics AX RunBase framework has the following advantages:

  1. All future updates are integrated automatically
  2. Common layout of the dialog
  3. Remembering the user selections from the last run
  4. Easy to implement

To implement Microsoft Dynamics AX RunBase framework, extend a class with RunBaseBatch.

Pre-requisites

  1. Microsoft Dynamics AX 2012
  2. The batch server must be configured

Important Methods

  1. Run

    Run is the central method of the Dynamics AX RunBase framework and is where all business logic is written. All information manipulation statements are placed in this method.

  2. Description

    The 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 the batch queue.

  3. Main

    Main is a static method which gives the entry point for a batch job. This procedure calls the prompt method, which calls RunBase dialog, and run method which processes the batch job.

Scenario

As part of this tutorial, RunBase class will mark all customers on-hold who have exceeded their credit limit.

Steps

  1. First, create a new class. Open AOT -> Classes
  2. Right-click on the Classes, choose New Class and create a new RunBaseDemo class

  3. Open the class declaration by right-clicking on the RunBaseDemo class and choosing View Code
  4. Write the following code:
  5. Add a new method and name it as the description. Write the following code in the method:

    client server static ClassDescription description()
    {
        return “Mark customers on-hold”;
    }

  6. Include 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();
    }
    }

  7. Override the run method and write the below 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”);
    }
    }

  8. Run the job by right-clicking on the RunBaseDemo class and choose Open. Alternatively, the job can also be called from the menu item
    RunBaseDemo

    RunBaseDemo

  9. The RunBase framework dialog will open
  10. There are 2 ways to run the batch job, only once and periodically
    1. If once, click OK. Use this option if you want to run job just this time
    2. If periodically, schedule the batch job. Use this option if you want to run job periodically. Follow the below steps to schedule the batch job
      • Check the Batch processing box
      • Choose the respective batch group from the Batch group drop down
      • Click on the Recurrence button
  11. In the Recurrence dialog, set the appropriate schedule and click OK.
  12. Click OK to schedule. It will now run the job according to inputted schedule.

Batch job history can be viewed from System administration -> Inquiries -> Batch jobs -> Batch job history

Share This Post

Leave a Reply

avatar
  Subscribe  
Notify of
Skip to toolbar