Developing Reports Using RDP and Report Contracts

With the help of this book you’ll soon be creating reports that are more graphic and more easily distributed. It’s a complete guide to the technical side of developing SSRS reports for Microsoft Dynamics AX 2012.

(For more resources related to this topic, see here.)

The Report data provider class

A Report data provider class is commonly known as RDP. RDP is the data source type which is available when we add a new dataset to the report in Visual Studio. RDP is a class which resides inside AX and executes the business logic, processes the data, and returns a dataset which is rendered in the report. A Report data provider class should be ideally used in the following cases:

  • We cannot directly use a query to access the data from the database
  • The data has to prepare on the basis of business logic

To define a Report data provider class, we use the following syntax:

Sample RDP

The Report contract class

Report contracts in AX 2012 are used for defining parameters to the SSRS report. We can define any number of parameters using X++ statements of any data type, which can be passed on to the RDP class. And then, we can use the same contracts to query data from the database engine which will decrease an overhead on execution of a query in SQL.

To define a Report contract class we use the following syntax:

Report Contract

Walkthrough – Creating an Auto Design report using the RDP class

Scenario

Matt, a Sales manager, needs a report to analyze total sales for customers.

This walkthrough illustrates the following tasks:

  • Creating a Report data provider class
  • Creating a Report Model project
  • Creating a Table report using Auto Design
  • Saving to AOT, deploying, and running the report

Prerequisites

To learn and implement the following walkthrough, you must have:

  • Microsoft Dynamics AX 2012 with sample data
  • Microsoft Visual Studio 2010 with Microsoft Dynamics AX reporting extension
  • Microsoft Dynamics AX 2012 SQL Server Reporting Services

Creating a Report data provider class

  1. Open Microsoft Dynamics AX 2012 from the Start menu.
  2. Open the development workspace. You can do it in either of the following ways:
    1. Press Ctrl + D to open AOT in Development Workspace.
    2. Press Ctrl + Shift + P to open Projects in Development Workspace.
    3. Press Alt + W to open windows and select New Development Workspace.
    4. Press Ctrl + Shift + W to open New Development Workspace.
  3. Navigate to the AOT | Classes node.
  4. Right-click on the Classes node, and click on New | Class.
  5. Double-click on the class created and change the class declaration, as shown in the following code:

    class SrsRDPSample extends SRSReportDataProviderBase{ CustTransTotalSales custTransTotalSales; }

  6. Right-click on the SrsRDPSample class and select New | Method.
  7. Modify the method, as shown in the following code:

    [SRSReportDataSetAttribute('CustSales')] public CustTransTotalSales getTmpCustTable(){ return custTransTotalSales; }

  8. Right-click on the SrsRDPSample class and navigate to Override method | processReport.
  9. Modify the method, as shown in the following code:

    public void processReport(){ select * from custTransTotalSales; }

Creating a Report Model project

  1. Start Visual Studio and press Ctrl + N to create a new project.
  2. Select Microsoft Dynamics AX under Installed Templates from the left pane, and select Report Model.
  3. Provide a name for the project as CustomerTotalSales_Autodesign.

    New project

Creating a Table report using Auto Design

  1. Right-click on Solution, select Report under the Add submenu. Select the report and rename it to CustTotalSales_Autodesign.
  2. Right-click on Datasets and click on Add dataset.
  3. Modify the following properties for the newly added dataset:
    1. Data source to Microsoft Dynamics AX.
    2. Data source type to Query.
    3. Default Layout to Matrix.
    4. Name to CustTotalSalesDS.
  4. Switch to the Query property, and click on the button besides the name of the entity button to open the Query dialog.
  5. Select SrsRDPSample from the list and click on the Next button.

    New dataset: CustTotalSalesDS

  6. Select all fields from CustSales.
  7. Drag-and-drop CustTotalSalesDS to the Design section of the report. This will create a new Auto Design named as AutoDesign1.
  8. Select AutoDesign1, go to Properties, and set the following properties:
    1. LayoutTemplate to ReportLayoutStyleTemplate
    2. Title to Customer sales.
  9. Select CustTotalSalesDS under AutoDesign1, and set the following properties:
    1. StyleTemplate to TableStyleAlternatingRowsTemplate.
    2. Title to Customer sales.
  10. Drag the AccountNum field from the Data node to Groupings.
  11. Drag the TransDate field to the Sorting node.
  12. Under the Data node, select only the TransDate, AmountMST, CurrencyCode, DocumentDate, DueDate, LastSettleDate, PaymMode, and TransType1 fields.

    Report design

Saving to AOT, deploying, and running the report

Save the report to AOT and Deploy to the Report Server, and then run the report.

Summary

In this article we covered Report data provider (RDP) class and Report contract class. We also learned how to implement these classes for our reporting needs. We learned creating an Auto Design report using the RDP class by following the step-by-step walkthrough.

Resources for Article:


Further resources on this subject:


Books to Consider

comments powered by Disqus