Question

I'd like to create a batch job in X++ for Microsoft Axapta 3.0 (Dynamics AX).

How can I create a job which executes an X++ function like this one?

static void ExternalDataRead(Args _args)
{
...
}
Was it helpful?

Solution

Here's the bare minimum needed to create a batch job in AX:

Create a batch job by creating a new class that extends the RunBaseBatch class:

class MyBatchJob extends RunBaseBatch
{
}

Implement the abstract method pack():

public container pack()
{
    return connull();
}

Implement the abstract method unpack():

public boolean unpack(container packedClass)
{
    return true;
}

Override the run() method with the code you want to execute:

public void run()
{
    ;
    ...
    info("MyBatchJob completed");
}

Add a static main method to your class to create an instance of your class and call the standard RunBaseBatch dialog:

static void main(Args _args)
{
    MyBatchJob myBatchJob = new MyBatchJob();
    ;
    if(myBatchJob.prompt())
    {
        myBatchJob.run();
    }
}

If you want your batch job to have a description in the batch list, add a static description method to your class:

server client static public ClassDescription description()
{
    return "My batch job";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top