Error on Purchase order posting in Ax 2012

 If You are getting following error on  Purchase order posting in Ax 2012
Error Description

Cannot execute a data definition language command on accounting distribution (AccountingDistributionTmpJournalize). Amount in transaction currency: 0,00.
The SQL database has issued an error.
 Object Server 01: 
 [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 
'tempdb.DBO.t100007_093C403F6242343F93ED4D1F8739A'.
Error Message  INSERT INTO tempdb."DBO".t100007_093323236220423232323 (TRANSACTIONCURRENCYAMOUNT,ACCOUNTINGDISTRIBUTION,RECVERSION,PARTITION) SELECT T1.TRANSACTIONCURRENCYAMOUNT,T1.RECID,1,5637144576 FROM ACCOUNTINGDISTRIBUTION T1 WHERE ((T1.PARTITION=5637144576) AND ((T1.REFERENCEROLE=3) AND (T1.SOURCEDOCUMENTLINE<>563343466))) AND EXISTS (SELECT 'x' FROM ACCOUNTINGDISTRIBUTION T2 WHERE ((T2.PARTITION=5637144576) AND (((T2.SOURCEDOCUMENTLINE=5637251266) AND (T2.MONETARYAMOUNT=1)) AND (T2.RECID=T1.REFERENCEDISTRIBUTION))) AND NOT (EXISTS (SELECT 'x' FROM ACCOUNTINGDISTRIBUTION T3 WHERE ((T3.PARTITION=5233244576) AND ((T3.REFERENCEDISTRIBUTION=T2.RECID) AND (T3.REFERENCEROLE=1))))))
Error Message (09:01:09 am) session 22 (s.ali)
Error Message (09:01:09 am)\Posting An error occurred during update
Error Message (09:01:09 am)\Posting Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown.
   at Dynamics.Ax.Application.FormletterService.Run() in FormletterService.run.xpp:line 220
   at Dynamics.Ax.Application.FormletterService.Postpurchaseorderinvoice(PurchFormLetterInvoiceContract _contract) in FormletterService.postPurchaseOrderInvoice.xpp:line 14
   at FormletterService::postPurchaseOrderInvoice(Object , Object[] )
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)
   at Dynamics.Ax.Application.SysOperationServiceController.Runoperation(Boolean _async) in SysOperationServiceController.runOperation.xpp:line 93
   at Dynamics.Ax.Application.SysOperationServiceController.runServiceOperation(Object[] parameters) in SysOperationServiceController.runServiceOperation.xpp:line 22
   at SysOperationServiceController::runServiceOperation(Object[] )
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethod(Object[] _params) in SysDictClass.invokeStaticMethod.xpp:line 26
   at SysDictClass::invokeStaticMethod(Object[] )
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
   at Microsoft.Dynamics.Ax.Xpp.PredefinedFunctions.runAsInvoke(String className, String staticMethodName, Object[] parms, Object[]& exportInfolog)

Solution

1. Restart Ax and Sql server to get resolve this issue.
2. If still issue exists then do the following.

Stop the AOS

Delete all of the files in the C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL directory

but do not delete folder inside it then give full compile.



Restart ax service then check this issue resolved.