Showing posts with label Production Order Status. Show all posts
Showing posts with label Production Order Status. Show all posts

Friday, November 7, 2014

How to Change the status of the Production Order to Estimated Status in AX 2012 using X++ ?

Hello Everyone,

I hope you are having a great week and you are eagerly waiting for the weekend.

Today, I am going to be talking on how we can change the status of the the production order to "Estimated" status in AX 2012 using X++.

The basic steps are to:
1. Declare the variables
2. Find the production order.
3. Initialize the associated classes - ProdMultiCostEstimation  &  RunBaseMultiParm
4. Pass the production table and default parameters
5. Run the class.

Here is the code:

public static void estimateProductionOrder(Args args)
{    
    ProdTable               prodTable;
    ProdMultiCostEstimation ProdMultiCostEstimation;

    prodTable   = ProdTable::find('P000012');


    //init ProdStartup
    ProdMultiCostEstimation = ProdMultiCostEstimation::construct(new args());

    //init default parameter
    RunBaseMultiParm::initParm(ProdMultiCostEstimation);

    //parm ProdTable, you can do this muliple times in case you want to update
    //more than one production at a time

    ProdMultiCostEstimation.insert(prodTable, ProdMultiCostEstimation.defaultParmBuffer());

    //Do update
    ProdMultiCostEstimation.run();

    info('Estimated');
}

Here is the a snapshot of the production order status: