Clean Up Production Orders - Song Nghia - Microsoft Dynamics Partner

Song Nghia - Microsoft Dynamics Partner

Song Nghia - Microsoft Dynamics Partner

Breaking

Friday, January 22, 2021

Clean Up Production Orders

Clean Up Production Orders

Song Nghia - Business Analyst

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.

AX 2012

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)
Calculations (prodCalcTrans)
Production Journal Table (prodJournalTable)
BOM journal Transactions (prodJournalBOM)
Production Journal Transactions (prodJournalProd)
Routing journal transactions (prodJournalRoute)

This will very effectively remove any production order and its related records but it leaves all inventory and financial tracking in place.

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);
        prodTableDeleteQuery.whereClause(this.buildDeleteProductionOrdersWhereClause(_prodTable));
        
        return prodTableDeleteQuery;
    }

    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)));
    }


Thanks for: http://www.atomicax.com/article/clean-production-orders

No comments:

Post a Comment