Dynamics 101
A Rand Group Knowledge Center

Developing a SSRS report using the Report Data Provider in Microsoft Dynamics AX 2012

Overview

There are multiple methods to develop SSRS reports in Microsoft Dynamics AX 2012. This tutorial will guide you in developing Report Data Provider (RDP) based SSRS reports.

RDP based SSRS Reports are used when complex business logic cannot be achieved using AOT query.

Pre-requisites

  1. Microsoft Dynamics AX 2012
  2. Visual studio 2012
  3. SQL Server Reporting Services (SSRS) must be configured
  4. Reporting services extensions must be installed in Dynamics AX

Important Concepts

  1. Report Data Provider (RDP) Class

  2. Report Data Provider Class is an X++ class that is used to access and process data for a SSRS report. The RDP class processes the business logic based on a specified parameter and/or query and returns a dataset to the reporting services. In order to create a RDP class in AX, you have to extend that class with SRSReportDataProviderBase. This tells AX that this class will be used by reporting services to process the data.

    Two important attributes are used in RDP classes:

    1. SRSReportQueryAttribute: specifies which AOT query will be used in this report. If the RDP class uses an AOT query to process data, define this attribute at the beginning of the class.
    2. SRSReportParameterAttribute: defines the data contract class that will be used by this report to prompt for parameter values. If the RDP class contains any parameters this define this attribute at the beginning of the class.

    Both the attributes are optional. If the report does not use any query or does not want any parameter to filter report data, these attributes do not need to be used.

  3. Data Contract Class

  4. A data contract class is an X++ class which contains parm methods with the DataMemberAttribute defined at the beginning of the method. This class is used to define one or more parameters that will be used in a SSRS report.

  5. Table

An AX table is used as the dataset to store data for the report. The RDP class processes the data and stores it in the table which is then used by a SSRS report to render data.

A table can be a temporary table (InMemory or TempDB) or a regular table, but it is Microsoft best practice to use a temporary table.

The type of temporary table is based upon the performance considerations. InMemory temporary table is used when the data set is small, while TempDB is normally used for larger datasets to improve performance.

Scenario

As part of this tutorial, the report will print a list of customers and their invoiced sales order counts.

Steps

  1. First of all, create a temporary table. Open AOT à Date Dictionary à Tables.
  2. Right Click on Tables and create a new Table called CustReportRDPDemoTmp.
  3. Set the TableType property to InMemory. This will define the table as a temporary table.
  4.  

     

  5. Expand the CustReportRDPDemoTmp table node and add the following fields in the table:
  6.  

    S. No. Field name Extended Data Type Label
    1 CustAccount CustAccount
    2 Name Name
    3 SalesOrderInvoiceCount Integer Sales order invoiced

     

  7. The final table should look like the following:
  8.  

     

  9. Now create a RDP class. Go to Classes and create a new class called CustReportRDPDemoDP by right clicking on Classes and selecting New Class. It is a best practice to suffix the RDP class name with DP .
  10.  

     

  11. Open the Class declaration by right clicking on it and selecting View code.
  12.  

     

  13. Now write the following code:
  14. Add a new method and name it getCustReportRDPDemoTmp. This method is mandatory because reporting services uses this method to get the table buffer containing the processed data. The SRSReportDataSetAttribute attribute is used to indicate the temporary table name and also tells the reporting services to use this method to retrieve the processed data.
  15. Write the following code in the method:
  16. Add a new method and name it processReport. This method contains the business logic and is called by reporting services to generate data.
  17. This method will query customer details and fill the temporary table buffer. Write the following code in the method:
  18. Now create a new report. Since the development of a SSRS report is done in Visual studio, we first need to create a new project in Visual studio.
  19. Open Visual studio. Go to File à New à Project
  20. In the Installed templates section select Microsoft Dynamics AX and then select Report Model in the right pane. Name the project RDPBasedDemo and press Ok.
  21.  

     

  22. A new project will be created as shown below.
  23.  

     

  24. Now add a new report in the project by right clicking on the project RDPBasedDemo à Add à Report.
  25.  

  26. A report will be added to the project with the name Report1. Rename the report RDPBasedDemo.
  27. Now double click the report to open it.
  28.  

  29. The description of the individual node is given below:
    1. Datasets: Datasets retrieve data from RDP class. It acts as a bridge between AX and the SSRS report. Only the fields added in the datasets can be used in a report.
    2. Designs: It defines the layout of the report.
    3. Images: It contains the images that you want to display in the SSRS report.
    4. Data Methods: It contains the business logic which can then be used in the report.
    5. Parameters: It is used to apply filtering to the data in a report. All the parameters defined in the data contract class are automatically added here when the RDP class is defined in the datasets.

  30. Now you will want to create a new Dataset by right clicking Datasets àAdd Dataset. Name it CustDetail.
  31.  

     

  32. Select the CustDetail dataset and open the properties window. Set the Data Source Type to Report Data Provider. Then select the Query field. An ellipse button appears. Click it to open a dialog box.
  33.  

     

  34. This dialog box lists all the RDP classes present in the AOT. Select CustReportRDPDemoDP and press Next.
  35.  

     

  36. Select the fields to be displayed in the report and press OK. Only the fields selected in this dialog box can be shown in the report.
  37.  

     

  38. There are two types of designs that can be created in a SSRS report:
    1. Auto design: Visual studio automatically creates a design based on the dataset provided. Auto design is the preferred method because it is easy and usually fulfills the majority scenarios.
    2. Precision Design: This is used when you need custom placement of fields or the layout of the report is too complex.

  39. In this demo we will use Auto Design. Now right click the Designs nodeàAdd àAuto Design. A new design is added. Rename it Design. It is recommended that you set the name of the Design to either ‘Design‘ or ‘Report‘.
  40.  

     

  41. Now drag the CustDetail form to the Datasets node and drop it on the Design node. A table will be created which contain all the fields present in the data set. These fields will appear in the same order as in the report. So if you want to arrange the fields, right click the field and select either ‘move up’ or ‘move down’.
  42. The final design should look like the following:
  43.  

     

  44. Now we have to define the layout of the report. Visual studio provides built in templates. Select the Design and open the properties window. Select ReportLayoutStyleTemplate in the LayoutTemplate field. Give a suitable title to the report.
  45.  

     

  46. Select CustDetailTable under the Design node and open the properties window. Select TableStyleAlternatingRowsTemplate in the Style Template field.
  47.  

     

  48. The report is now completed and can be viewed. To preview the report, select the Design node, right click it and select preview.
  49.  

     

  50. Select the Report tab. The report will appear as shown below:
  51.  

  52. To view this report from AX, Add the report to AOT and create an Output menu item and set the appropriate Properties. For further details on creating SSRS reporting, refer to our previous article ‘Developing SSRS report using Query‘.

 

  • wilkssh

    Everything in the tutorial is very clear. However, when I try to select the data provider class (step 23) the class I created is not in the list. The classes compile fine in AX and I can even see the class in the Visual Studio Application Explorer.

    Any troubleshooting tips for this?

    • http://www.dynamics101.com/ Dynamics 101

      Glad the tutorial was helpful! Try the following to see it fixes your problem:

      1) Check the class to ensure it is extended with the correct class

      2) Refresh the Caches or try to restart the AX service

      Hope this helps!

    • Gustavo Bonato

      I am having the same problem. Did you have any solution?

  • jozefin

    Hello,
    This was by far the best tutorial I’ve read in Ax SSRS Development. I have a question myself: I created a report using a DataProviderClass. My temp table Works fine but now I need to pass a string parameter to this report.
    1. I have to put this report behind a button in a form. So in the clicked event, how can I pass my parameter to the report? (I also have the parameter in the datacontract).
    2. When I try to run the report, the popup for default Ax parameter entries appear. I do not want the popup, I just need the report to be rendered, like a SalesInvoiceReport. What should I do? (By the way, I checked the SalesInvoice and it didnt help much)
    Thanks in advance

  • Darshana Parnaik

    Hello,
    Is it possible to open RDP report (not using query)
    from a form are needed to show selected record details.

  • MAKSIL

    Hello ,

    Sorry, My question is out of subject. I added filters on report SSRS and i used a result from a view (Not a query) to my report. The report work fine but when i went to filter some date or CustomerName, it doesn’t work.

    My question is :
    it’s possible to use a filter in report who uses a View SQL?