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); }
0 comments:
Post a Comment