Monday, December 9, 2013

Management Reporter 2012 RU6, CU7 integration issue causing TempDb size to blow

In Management reporter 2012, starting from RU6, Microsoft introduces customer and vendor attributes, however under some circumstances this might cause the TempDb size to blow out.

The SQL query that causes the issue is:
set dateformat mdy;
SELECT COUNT(DISTINCT GJAE.RECID) FROM (SELECT
GJAE.RECID, GJAE.Partition as Partition, GJAE.TRANSACTIONCURRENCYAMOUNT, GJAE.ACCOUNTINGCURRENCYAMOUNT, GJAE.REPORTINGCURRENCYAMOUNT,
                                  GJAE.QUANTITY, GJAE.ISCREDIT, GJAE.TRANSACTIONCURRENCYCODE, C.TXT AS CURRENCYNAME, C.SYMBOL AS CURRENCYSYMBOL, GJAE.PAYMENTREFERENCE, GJAE.POSTINGTYPE, GJAE.TEXT,
                                  GJAE.GENERALJOURNALENTRY, GJAE.REASONREF, GJAE.LEDGERDIMENSION,
                                  GJE.ACCOUNTINGDATE, GJE.JOURNALNUMBER, GJE.POSTINGLAYER, GJE.LEDGER, GJE.FISCALCALENDARPERIOD, GJE.ACKNOWLEDGEMENTDATE,
                                  GJE.DOCUMENTDATE, GJE.LEDGERPOSTINGJOURNAL, GJE.DOCUMENTNUMBER, GJE.JOURNALCATEGORY,
                                  DALVV.DIMENSIONATTRIBUTE, DALVV.DISPLAYVALUE, DALVV.ENTITYINSTANCE,
                                  RTR.REASON, RTR.REASONCOMMENT,
                                  LE.CONSOLIDATEDCOMPANY, LE.ISBRIDGINGPOSTING, MA.AccountCategoryRef, VDPT.NAME as VENDORNAME, CDPT.NAME as CUSTOMERNAME,
                                  LJT.NAME as JOURNALDESCRIPTION, LJT.JOURNALTYPE, LJT.JOURNALNAME,
                                  GJE.SUBLEDGERVOUCHER, TRT.TRACENUM, TRT.REVERSED, LJTR.REVERSEENTRY, NULL as MODIFIEDDATETIME, NULL as MODIFIEDBY, LJT.POSTEDDATETIME as JOURNALENTRYDATE, NULL as HISTORICALEXCHANGERATEDATE
FROM GENERALJOURNALACCOUNTENTRY GJAE
                           left outer join GENERALJOURNALENTRY GJE on GJAE.GENERALJOURNALENTRY = GJE.RECID
                           left outer join DIMENSIONATTRIBUTELEVELVALUEVIEW DALVV on GJAE.LEDGERDIMENSION = DALVV.VALUECOMBINATIONRECID
                           left outer join REASONTABLEREF RTR on GJAE.REASONREF = RTR.RECID
                           left outer join LEDGERENTRY LE on GJAE.RECID = LE.GENERALJOURNALACCOUNTENTRY
                           left outer join LEDGERENTRYJOURNAL LEJ on GJE.LEDGERENTRYJOURNAL = LEJ.RECID
                           left outer join LEDGERJOURNALTABLE LJT on LEJ.JOURNALNUMBER = LJT.JOURNALNUM
                           left outer join CURRENCY C on GJAE.TRANSACTIONCURRENCYCODE = C.CURRENCYCODE and C.Partition = GJAE.Partition
                           left outer join VENDTRANS VTR on GJE.SUBLEDGERVOUCHER = VTR.VOUCHER and GJE.DOCUMENTDATE = VTR.DOCUMENTDATE
                           left outer join VENDTABLE VTA on VTR.ACCOUNTNUM = VTA.ACCOUNTNUM
                           left outer join DIRPARTYTABLE VDPT on VTA.PARTY = VDPT.RECID
                           left outer join CUSTTRANS CTR on GJE.SUBLEDGERVOUCHER = CTR.VOUCHER and GJE.DOCUMENTDATE = CTR.DOCUMENTDATE
                           left outer join CUSTTABLE CTA on CTR.ACCOUNTNUM = CTA.ACCOUNTNUM
                           left outer join DIRPARTYTABLE CDPT on CTA.PARTY = CDPT.RECID
                           left outer join TRANSACTIONREVERSALTRANS TRT on GJAE.RECID = TRT.REFRECID and TRT.REFTABLEID = 3119
                           left outer join LEDGERJOURNALTRANS LJTR ON LJTR.REVERSEENTRY = 1 AND GJE.SUBLEDGERVOUCHER = LJTR.VOUCHER AND GJE.ACCOUNTINGDATE = LJTR.TRANSDATE
                           left join DIMENSIONATTRIBUTE DA ON DA.RECID = DALVV.DIMENSIONATTRIBUTE
                           left join MAINACCOUNT MA on MA.RECID = DALVV.ENTITYINSTANCE AND DA.TYPE = 2  LEFT OUTER JOIN CHANGETABLE(CHANGES GENERALJOURNALACCOUNTENTRY, 0) GJAE_CT ON GJAE.RECID = GJAE_CT.RECID
 LEFT OUTER JOIN CHANGETABLE(CHANGES GENERALJOURNALENTRY, 0) GJE_CT ON GJE.RECID = GJE_CT.RECID
 LEFT OUTER JOIN CHANGETABLE(CHANGES LEDGERJOURNALTABLE, 0) LJT_CT ON LJT.JOURNALNUM = LJT_CT.JOURNALNUM
 LEFT OUTER JOIN CHANGETABLE(CHANGES LEDGERJOURNALTRANS, 0) LJTR_CT ON LJTR.RECID = LJTR_CT.RECID
) GJAE WHERE GJAE.POSTINGTYPE <> 19


As you can see the query does not consider partition or dataAreaId when do the joins to the CustTable, CustTrans, VendTable, and VendTrans. Depending what kind of data you have, this might cause the TempDb size to blow out of the proportion.

In our case I had a 169GB AX database, and the TempDb size blew to over 500GB because of this query. The database does have a lot of customers and vendors using the same account numbers across 130+ companies.

I was told to use Management reporter RU5 instead, where it doesn't have any customer and vendor attributes, and that worked fine.

Monday, March 11, 2013

AX2012 Help server error - Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list

When you open the Help menu, it displays an error dialog saying "Unable to contact the server".
When opening the help server URL using an internet browser, it displays an error saying "Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list".

Solution:
Open a command prompt and run this:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

Wednesday, January 16, 2013

Intermittent SSRS report error: System.Security.Permissions.EnvironmentPermission when running reports for the first time

Just today I had an issue with Dynamics AX 2012 SSRS report when running reports for the first time. It sometimes came up with this error:
"The DefaultValue expression for the report parameter ‘AX_CompanyName’ contains an error: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsRuntimeErrorInExpression)"

Then I've found a helpful blog that seems to explain the same issue in http://blogs.msdn.com/b/axsupport/archive/2012/02/02/microsoft-dynamics-ax-2012-reporting-extensions-error-system-security-permissions-environmentpermission-while-running-report.aspx

So basically I need to make some changes in the rssrvpolicy.config to change the permission set name from Execution to FullTrust and then restart the SSRS service.

You can find the rssrvpolicy.config file in:


  • If you are using SQL Server 2008, the default location of this file is: \Program Files\Microsoft SQL Server\MSRS10.[SSRSInstanceName]\Reporting Services\ReportServer
  • If you are using SQL Server 2008 R2, the default location of this file is: \Program Files\Microsoft SQL Server\MSRS10_50.[SSRSInstanceName]\Reporting Services\ReportServer
  • If you are using SQL Server 2012, the default location of this file is: \Program Files\Microsoft SQL Server\MSRS11.[SSRSInstanceName]\Reporting Services\ReportServer



<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Report_Expressions_Default_Permissions"
Description="This code group grants default permissions for code in report expressions and Code element. ">