Showing posts with label SSRS. Show all posts
Showing posts with label SSRS. Show all posts

Thursday, July 14, 2016

Open pure SSRS based reports in AX client

Normally you would create SSRS reports in AX using the inbuilt reporting frameworks, for example the report data provider (RDP) framework.
https://technet.microsoft.com/en-us/library/ee873263.aspx

But in case you have pure SSRS based reports, created and hosted outside of AX and you want someway to integrate them in AX, there is no "out of the box" way around. But its not that difficult. What we can do is host the SSRS report's URL inside a web control in AX, as a SSRS report is essentially just a URL.

To begin with you need to determine your SSRS reports URL links. Some information on that.
https://msdn.microsoft.com/en-us/library/dd255286.aspx

The report URL is essentially made up of two parts.
1. The link to the SSRS report server where all reports are hosted.
For example, "http://abcServer/ReportServer"

So you could create a parameter say abcServerURL (table SRSServers) in System administration, report servers form to store this bit as it would be same for all your SSRS reports. Please note the SRSServers table is global, same value across all partitions and companies. If you dont want to have same value for all partitions you would want to store this value in a different table. If you have multiple partitions, multiple companies on the same AOS cluster, this property would be shared, which means same reports would be made available to all the users. Your BI consultant should implement a security layer to map the user ids with the exact partition/company data they should be exposed to. Otherwise you would expose other companies data to a user!

2. The part of the URL string that points to the exact report
For example, "/Pages/ReportViewer.aspx?%2fReports%2f+Sales+Report&rs:Command=Render"
We would create one form for each report and 'hardcode' this second bit of the URL inside each form.

Thus, the complete URL will be a concatenation of the two parts
"http://abcServer/ReportServer/Pages/ReportViewer.aspx?%2fReports%2f+Sales+Report&rs:Command=Render"

So you might have 10 reports, all the 10 reports will have the same first part but a different second part, pointing to the exact report.

Next you need to design the form that hosts the web control. Create a form for each report. In design, add a managedHost control.



Finally in the init method of the form, we will "create" the URL and launch it.

 public void init()  
 {  
   System.Windows.Forms.WebBrowser  ssrsBrowser;  
   SRSServers                       sRSServers;  
   str                              url;  

   super();
  
   select firstonly abcServerURL from sRSServers;  
   if (!sRSServers.abcServerURL)  
     throw error ("Report server URL not setup");  

   url = sRSServers.abcServerURL + "/Pages/ReportViewer.aspx?%2fReports%2fSales+Report&rs:Command=Render";  
   ssrsBrowser= managedhost.control();  
   ssrsBrowser.Navigate(url);  
 }  

Thats it. You have successfully managed to get pure SSRS power inside your AX. Cheers.

Saturday, February 16, 2013

Multiple Designs in SSRS

Developers who have had their hands dirty playing with SSRS in 2012 must be well aware of the Report Data Provider framework. RDP is the new way AX wants you to make reports in SSRS. In a way, Microsoft wants to put all the business logic back in X++ and dissuade developers from using the Visual Studio data methods. In case, all this sounds greek to you, please browse MSDN. 

Few important concepts here: 
  • Temporary table – RDP class fills a temporary table with data that will be used by Reporting Services to display the report. 
  • Data Contract Class – defines the parameters in the report. 
  • Report Data Provider Class – processes business logic based on a query and parameters defined in the data contract class, and then returns the tables as a dataset for the report. 
  • Controller class – control the report execution and dialog forms. Report controllers can be used to modify report dialogs, validate report parameters and other validations necessary before report execution. 
  • UIBuilder class – enhance the dialog more. 

Today, I will touch upon a small but interesting topic related to this. One of the reports I was required to have two designs Summary/Detailed and based on the value in Summary checkbox in Dialog, decide at run-time which design to display. This logic resides in the Controller class, in method preRunModifyContract().

protected void preRunModifyContract()
{
    SalesMarginReportContract   dataContract = this.parmReportContract().parmRdpContract() as SalesMarginReportContract;

    if (dataContract.parmIsSummary())
    {
        this.parmReportContract().parmReportName(ssrsReportStr(SalesMarginReport, SummaryDesign));

    }
    else
    {
        this.parmReportContract().parmReportName(ssrsReportStr(SalesMarginReport, DetailedDesign));
    }

    super();
}