Creating Report Data Provider Based SSRS Reports in D365 F&O - A Complete Guide

Rumman Ansari   Software Engineer   2024-09-22 03:11:41   861  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

Report Data Provider Based SSRS Report in D365 F&O

Case Study 4: Create SSRS Report 

Problem statement:

Problem statement: Fetch total number of sales orders for customer C1 and C2 where they ordered Item-001, Item-002, Item-003.

The report must show the name of the company and company logo in header section. Also show name of report as “Customer-wise salesorders” in header. 

The report must have lines grouped by customer number. Show itemId, item description and count of salesId where itemId was ordered. 

The report design can be a simple tabular style design.

Create appropriate HeaderTmp and LineTmp tables, DP, contract and controller classes, output menu items and SSRS report. 

Solution:

Solution:  Read solution carefully.

Steps Performed: 

1) Identified the tables & created new project and then added 2 tables (i.e) SalesTable and SalesLine table & found out the required fields like ItemId, ItemDescription and the salesId. 

2) Created a temp table SalesOrderLineTmp” and assigned the table type property from regular to TempDB. 

3). Added the fields to it like ItemId, ItemDescription, TotalSalesOrder and CustAccount. 

4). Saved the project and performed the build and synch the table. 

5). Now created the DP class SalesOrderLineDP” and the controller class “SalesOrderLineController” 

6) Added the following code in the respective classes: 

Code for the Data Provider Class

Open DP class in designer mode and you can override the methods shown in the screenshot. processReport method already overridden.

How to add methods in DP class
Figure:

Extend the base class SRSReportDataProviderBase

Note: A Data Provider class extends SRSReportDataProviderBase and implements at least the processReport() method.

Each Data Provider class is decorated with the SRSReportParameterAttribute attribute that points to a particular Data Contract class, and optionally with the SRSReportQueryAttribute attribute that points to a dynamic query if such exists.

Additionally, for each of the data sets a method decorated with the SRSReportDataSetAttribute attribute should be implemented.

How to Create SSRS Report - in D365 F&O SSRS Report creation

Code for the Controller Class

7) Controller Class Code: 

Extend the base class SrsReportRunController 

How to Create SSRS Report - in D365 F&O

8) Then We added report inside our project and set Data Source Type: Report Data Provider also we selected the fields by clicking on the next button. and deployed the report. 

Also added following Reference Models:

  • ApplicationFoundation 
  • ApplicationPlatform 
  • ApplicationSuite 
  • ContactPerson 
  • Directory 
  • FiscalBooks 
  • SourceDocumentation 
  • SourceDocumentationTypes 

9) set query property to SalesOrderLineDp

10) Then we Synchronized with Database and build the project. 

11) Then we added Output Menu Item and the set the properties as follows: 

  • Object: SalesOrderLineController 
  • Object Type: Class 
  • Subscriber access level: Unset 
  • Needs Record: Yes 

12) Output Screen: 

How to Create SSRS Report - in D365 F&O

Not Mandatory Always: in DP class

Each Data Provider class is decorated with the SRSReportParameterAttribute attribute that points to a particular Data Contract class , and optionally with the SRSReportQueryAttribute attribute that points to a dynamic query if such exists.


[SRSReportParameterAttribute(classStr(ATNYLASalesOrderByCustomerContract))]
class ATNYLASalesOrderByCustomerDP extends SRSReportDataProviderBase 
{

ATNYLASaleOrderByCustomerTemp orderByCustomer;  // Buffer of temp DB
 
ATNYLASalesOrderByCustomerContract ATNYLASalesOrderByCustomerContract;

}

Data Contract Class:

See how data contract class look like.

 
[DataContractAttribute]
public class DocAgreementDocumentContract
{
    RecId  salesAgreementRecId;
    
    [
        DataMemberAttribute('SalesAgreementRecId'),
        SysOperationLabelAttribute(literalStr("@SYS190134")),
        SysOperationControlVisibilityAttribute(false)
    ]
    public RecId parmSalesAgreementRecId(RecId _salesAgreementRecId = salesAgreementRecId)
    {
        salesAgreementRecId = _salesAgreementRecId;
        return salesAgreementRecId;
    }
}