Let's walk through creating a standard Build VM
You are here
Clean Up Production Orders
Let's Clean Up Ended Production Orders!
If you need to clean up your production orders and their related journals as well as related info, then you'll want to look at the clean up functionality for production orders. If you want to clean up just the journals, please take a look at this.
Similar to the Production Journals clean up functionality, this will remove production journals but also more related into. This is also easier to use as its date driven rather than status driven so if you want to use it to clear our a closed year, this is a great option.
This will delete ended production orders (ProdTable) ended on or before the date you select with business logic and alerts disabled. Next, it will delete from the following:
Production BOM (ProdBOM)
Production Route (ProdRoute)
Route Jobs (ProdRouteJob)
Capactity Reservations (wrkCtrCapRes)
Production Journal Table (prodJournalTable)
BOM journal Transactions (prodJournalBOM)
Production Journal Transactions (prodJournalProd)
Routing journal transactions (prodJournalRoute)
Dynamics 365 for Finance and Supply Chain
Functionally, this is just like the AX 2012 version and can be found in the same place. However, similar the cleanup functionality for journals, this has an updated method for deleting Production Orders (ProdTable) records. Below are the 2 methods of most interest. They create a query using methods to wrap direct SQL rather than use a buffer with a row or set based operation ( like while select or delete_from )
private SysDaQueryObject buildDeleteProductionOrdersQuery(ProdTable _prodTable)
SysDaQueryObject prodTableDeleteQuery = new SysDaQueryObject(_prodTable);
protected SysDaBinaryExpression buildDeleteProductionOrdersWhereClause(ProdTable _prodTable)
return new SysDaAndExpression(
new SysDaEqualsExpression(new SysDaFieldExpression(_prodTable, fieldStr(ProdTable, ProdStatus)), new SysDaValueExpression(ProdStatus::Completed)),
new SysDaLessThanOrEqualsExpression(new SysDaFieldExpression(_prodTable, fieldStr(ProdTable, RealDate)), new SysDaValueExpression(realDateBefore)));