How to create an X++ batch job in Axapta 3.0?

你说的曾经没有我的故事 提交于 2019-12-07 09:14:31

问题


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)
{
...
}

回答1:


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";
}


来源:https://stackoverflow.com/questions/170088/how-to-create-an-x-batch-job-in-axapta-3-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!