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:


Tuesday, November 4, 2014

How to Create a Production Order in AX 2012 using X++ ?

Production orders come under Production Control module. The basics of production orders is that in manufacturing industry, everything that is produced needs to have a production order number associated with it so that if there is an ERP system present, the system can track & capture its exact manufacturing process.

In Microsoft Dynamics AX 2012 R2, with the advent of new functionality, the process has become simpler as well as complex with a lot more options to create a production order, configure the production cycle and configure the whole production module.

Below code snippet provides a simple way to create a production order using X++:


static void CreatePO_DD(Args _args)
{
    // Define Variables
    ProdTable       prodtable;
    InventTable     inventTable;
    InventDim       inventDim;
   
    ProdQty         qty     = 1000;
    ItemId          item    = 'A0001';

    ;

    // Initialize InventTable
    inventTable = inventTable::find(item);

    // Initialize the default values
    prodtable.initValue();

    // You have the option to initialize from inventory table as well
    prodtable.initFromInventTable(inventTable);

    prodtable.ItemId                = inventTable.ItemId;
    prodtable.DlvDate               = today();
    prodtable.QtySched              = qty;
    prodtable.RemainInventPhysical  = qty;

    // Initialize InventDim table for inventory dimensions defaulting from item id

    inventDim.initValue();

    // Set the active BOM and Route as without these values a production order won't be created
    prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
                                             prodtable.BOMDate,
                                             prodtable.QtySched,
                                             inventDim).BOMId;

    prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
                                                 prodtable.BOMDate,
                                                 prodtable.QtySched,
                                                 inventDim).RouteId;

    // Initialize BOMVersion
    prodtable.initBOMVersion();

    // Initialize RouteVersion
    prodtable.initRouteVersion();

    //Use ProdTableType class to create the production order
    prodtable.type().insert();

    setPrefix( 'Production Order Number');
    info(prodtable.ProdId);
}

Sunday, November 2, 2014

First Dynamics AX Post

Hello Everyone,

I am starting this blog to share the dynamics AX knowledge that I have acquired during my work experience with everyone.

My blog posts will revolve around Dynamics AX 2012, Application Integration Framework, Workflows, SSRS Reporting, Data Import Export Framework, Enterprise Portal and pretty much anything that is associated with AX.

Hope to see you reading my posts in future.

Regards,
DD