Showing posts with label Dynamics AX 2012. Show all posts
Showing posts with label Dynamics AX 2012. Show all posts

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