Basics of creating SSRS reports in Axapta (AX 2012)

Updated: 24.10.2012

The current version of Axapta, namely Dynamics AX 2012 (the AX2012) all reporting is built on MS Sql Server Reporting Services (SSRS), the use of old technology reporting is possible, but not desirable, and create reports in AX2012-based SSRS not quite trivial . To help new developers, we decided to write a short article describing the minimum necessary steps to create a report based on the SSRS.

In addition to creating report using Visual Studio, you need to create a set of classes at AX2012  for the report. After creating a new report in Visual Studio, determine the type of data source. Data sources, mainly use two types of Query - Query AX2012 and ReportDataProvider. Using the Data Source Query does not involve any additional actions other than to the query, if you want the data set does not meet any of the existing queries. When using the type of data source ReportDataProvider everything is not so transparent, it's about this implementation we describe below.
 
For the implementation of the report with the data source type ReportDataProvider, create a class inherits interface from a class SysOperationValidatable and fill out the necessary attributes for this class. Class attributes and methods, this new designs in AX2012, they are indicated before the definition of a class or method. In addition to this class to create a class of "controller" of our report, he should be the heir class SRSReportRunController.
 
Example for our case:
 
1. First, we define a class for the parameters of our report with attributes (attributes are specified in the construction of       "[ ]", separated by commas), a new class to inherit the interface of the system class «SysOperationValidatable». With the class parameters and attributes of the class, you can specify the parameters of the report, and their location within the options dialog, in addition you can write methods for the parameters that return a specific set of parameter values.

[

  1.  
  2. DataContractAttribute,
  3.  
  4. SysOperationContractProcessingAttribute(clasStr(SrsReportDataContractUIBuilder)),
  5.  
  6. SysOperationGroupAttribute(“Customer”,”Настройки клиента”,1, FormArrangeMetod::Vertical);
  7.  
  8. ]
  9.  
  10. Class NewReportParams implements SysOperationValidatable
  11.  
  12. {
  13.  
  14. CustAccount custAccount;
  15.  
  16. }

2. The method described by the parameter «CustAccount»

  1. [
  2.  
  3. DataMemberAttribute("CustAccount"),
  4.  
  5. SysOperationGroupMemberAttribute("Cust"),
  6.  
  7. SysOperationDisplayOrderAttribute("1"),
  8.  
  9. SysOperationLabelAttribute("Клиент"),
  10.  
  11. SysOperationHelpTextAttribute("Укажите код клиента")
  12.  
  13. ]
  14.  
  15. Public CustAccount parmCustAccount(CustAccount _custAccount = custAccount)
  16.  
  17. {
  18.  
  19. ;
  20.  
  21. custAccount = _custAccount;
  22.  
  23. return custAccount;
  24.  
  25. }

3. Class provider of our report:

  1. Class NewReportDataProvider extends SrsReportDataProviderPreProcess ;
  2. {
  3. }

To determine the class of providers, you can also use the class SrsReportDataProviderBase. Debug class inherits from SrsReportDataProviderBase not possible, this is our recommendation to use the class SrsReportDataProviderPreProcess, because it possible to debug AX2012, except for debugging, data on the use of different classes within them to work with sets of data.

SrsReportDataProviderBase class allows you to work with temporary tables in SrsReportDataProviderPreProcess to use regular tables with the included properties CreatedBy and CreatetransactionId, as temporary. First we create a table with the included properties NewReportTableTmp CreatedBy and CreatedTransactionID.

 
4. Class Definition provider with attributes (attributes are specified in the construction of "[ ]", separated by commas).

  1. [
  2.  
  3. SRSReportQueryAttribute(queyStr(QFromNewReport)), // request for the data set
  4.  
  5. SRSReportParameterAttribute(classStr(NewReportParams)) // Class of report parameters
  6.  
  7. ]
  8.  
  9. Class NewReportDataProvider extends SrsReportDataProviderPreProcess
  10.  
  11. {
  12.  
  13. }

5. The method returns a data source, you must mark the following attribute:

  1. [
  2.  
  3. SRSReportDataSetAttribute(‘RetSalesTable’)
  4.  
  5. ]
  6.  
  7. Public NewReportTableTmp NewRecord()
  8.  
  9. {
  10.  
  11. NewReportTableTmp NewReportTableTmp;
  12.  
  13. ;
  14.  
  15. Select NewReportTableTmp where NewReportTableTmp.custAccount ==000022;
  16.  
  17.  
  18.  
  19. Return NewReportTableTmp;
  20.  
  21. }

6. Further close the provider method processReport (), it is used to fill we created a "temporary" table data is necessary for us, that is, in this method, we can determine the appropriate algorithm for our data sample.

  1. public void processReport()
  2.  
  3. {
  4.  
  5. NewReportTableTmp NewReportTableTmp;
  6.  
  7. NewReportParams contract;
  8.  
  9. Query q;
  10.  
  11. QueryRun qr;
  12.  
  13.  
  14.  
  15. ;
  16.  
  17.  
  18.  
  19. NewReportTableTmp.setConnection(this.parmUserConnection());
  20.  
  21. contract = this.parmDataContract() as NewReportParams;
  22.  
  23. q = this.parmQuery();
  24.  
  25. qr = new QueryRun(q);
  26.  
  27.  
  28.  
  29. while ( qr.Next() )
  30.  
  31. {
  32.  
  33.  
  34. // We fill our table NewReportTableTmp
  35.  
  36. }
  37.  
  38.  
  39.  
  40. }

7. Creating a class report (previously in AX2012 in Visual Studio report was created «NewReport» in which the data source is created by our selected provider):

  1. Class NewReportControl extends SRSReportRunController
  2.  
  3. {
  4.  
  5. }

8. The main method of this class:

  1. Public static void main (Args _args)
  2.  
  3. {
  4.  
  5. NewReportControl controller;
  6.  
  7. ;
  8.  
  9. Controller = new NewReportControl();
  10.  
  11. Controller.parmreportName(SsrsReportStr(NewReport, Report)); //which report call
  12.  
  13. Controller.parmShowDialog(true); // Report Parameters dialog
  14.  
  15. Controller.parmDialogCaption(“Cap dialog”); // label in the header of the dialog
  16.  
  17. Controllrt.startOperation; // run a Report
  18.  
  19. }

Using the above described techniques, you can create very flexible options for reporting and to use the data sets produced "on the fly." In comparison with the standard platform to generate reports MS Dynamics AX previous versions, the design process began reporting simpler and more flexible, reducing the development of a new report, do not waste time on the development and design of the fit of the report itself.

The authors: Eugene Petrov, Oleg Maistrenko.

 

Other blog posts

14.11.2017
Why outsourcing company is more effective than In-house IT-specialists There are situations when in-house specialists spend most of their time awaiting requests or they cannot get their work...
26.09.2017
Microsoft Dynamics AX program decisions are constantly improving. At first, innovations come to European companies, and only after that to Russian enterprises.We aspire to be one step ahead in this...
28.08.2017
Notes of the summit and of Dynamics market in Russia. Neti has been specializing in AX development since 2003. Our sphere of interest is the cutting-edge MS Dynamics technology. We find, study...

Subscribe for blog updates

Get updated with our blog new articles via your email!


Subscribe now