Developing Reports Using RDP and Report Contracts

Exclusive offer: get 50% off this eBook here
Developing SSRS Reports for Dynamics AX

Developing SSRS Reports for Dynamics AX — Save 50%

A step-by-step guide to Microsoft Dynamics AX 2012 report development using real-world scenarios with this book and ebook

$22.99    $11.50
by Mukesh Hirwani | October 2013 | Enterprise Articles

In this article by Mukesh Hirwani, the author of Developing SSRS Reports for Dynamics AX, we will learn about developing reports using the Report data provider class and Report contracts.

In this article, we will learn about developing reports using the Report data provider class and Report contract class.

(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:


Developing SSRS Reports for Dynamics AX A step-by-step guide to Microsoft Dynamics AX 2012 report development using real-world scenarios with this book and ebook
Published: September 2013
eBook Price: $22.99
Book Price: $37.99
See more
Select your format and quantity:

About the Author :


Mukesh Hirwani

Mukesh Hirwani is currently working as a Technical Solution Architect with Microsoft Dynamics Gold Partner. The company provides specialized solutions to the family of Microsoft Dynamics Partners/Resellers/Customers.

Mukesh started his career back in the year 2008 parallel to his Post-graduation (Master of Science Studies in Software Engineering from the Birla Institute of Technology and Science). Since then, he has been a recognized Microsoft Certified Professional for AX in all the major areas: Development, Configuration and Installation, Integration, Financials, Projects, Customer Relationship Management, Human Resources, and Trade and Logistics. He has also been delivering trainings for AX Technical Track.

From 2008 to 2013, Mukesh has participated in over 12 Microsoft Dynamics AX implementations. He has handled a wide range of development, consulting, and leading roles, while always maintaining a significant role as an Enterprise Application Developer.

In the early days of the year 2013, Mukesh has worked with Microsoft for AX 2012 R2 learning material preparation.

Books From Packt


Microsoft Dynamics AX 2009 Development Cookbook
Microsoft Dynamics AX 2009 Development Cookbook

Microsoft Dynamics AX 2009 Administration
Microsoft Dynamics AX 2009 Administration

 Microsoft Dynamics AX 2012 Development Cookbook
Microsoft Dynamics AX 2012 Development Cookbook

Quality Assurance for Dynamics AX-Based ERP Solutions
Quality Assurance for Dynamics AX-Based ERP Solutions

 Microsoft Dynamics AX 2012 Security How-To [Instant]
Microsoft Dynamics AX 2012 Security How-To [Instant]

Microsoft Dynamics AX 2012 Services
Microsoft Dynamics AX 2012 Services

Extending Microsoft Dynamics AX 2012 Cookbook
Extending Microsoft Dynamics AX 2012 Cookbook

 Implementing Microsoft Dynamics AX 2012 with Sure Step 2012
Implementing Microsoft Dynamics AX 2012 with Sure Step 2012


Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software