As we see our in our Dynamics Ax Database - Table Sizes Posting the ProdParmStartup table was at 155 Gb, that's a lot of date for one table, we can clear some of that out.
From MSDN: The ProdParmStartUp table contains parameters that are used when starting up a production order. Each record defines the parameters for the startup of one production order (the parameters are thus connected to one production order).
Production order cleanup does not do anything with this table, you can clear ended production orders from this table. I know I said it is best practice to do everything through the application. You can either run the following SQL statement or create an X++ job based on the sql command. If this is the first time it is best to run it with the post date set from when you went live and increment it several months at a time, do this for each company that has production order data.
delete ProdParmStartup
from ProdParmStartup
Join ProdTable on ProdTable.ProdId = ProdParmStartup.ProdId AND
ProdTable.ProdStatus = '7' –- 7 = Ended prod orders
Where ProdParmStartup.postdate <='2012-01-01 00:00:00.000' --keep anything after this date
and ProdParmStartup.DATAAREAID = 'YourCompany'
Update:
Microsoft has considered this to be a problem and is looking at a design change in the next release, whenever that will happen. In the interim you can update the deleteProductions method in the \Classes\ProdTableCleanUp class with the following:
This assumes you are using the Production Order Cleanup routine in Production\Periodic\Clean-up.

Disclaimer: As with any code, be sure to test thoroughly in a NON-Production/TEST system before running in production. I am not responsible for anything that may go awry.
// ProdParmsStartup Table cleanup
prodParmStartup.skipDataMethods(true);
prodParmStartup.skipDeleteActions(true);
delete_from prodParmStartup
notexists join prodTable
where prodTable.ProdId == prodParmStartup.ProdId;
An alternative is to create a job that will clean the table when a production order is complete:
static void ProdParmStartup_Cleanup(Args _args)
{
ProdTable prodTable;
ProdParmStartup prodParmStartup;
While select prodTable Where prodTable.ProdStatus == ProdStatus::Completed
{
if (prodTable.RecId)
{
ttsbegin;
select forupdate firstonly prodParmStartup where prodParmStartup.ProdId == prodTable.ProdId;
try
{
if (prodParmStartup.RecId)
{
prodParmStartup.delete();
}
}
catch (exception::UpdateConflict)
retry;
ttscommit;
}
}
}
1 Comment
Sanjeev said
This is very good.
Thank you