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();
}

4 comments:

  1. Your business case matches mine exactly, need a summary/detail version of a report. I used your code above and I get a stack trace error on your line 05 saying the contract object is not initialized. Can you show what is in your main() method? There must be some kind of contract init you are doing that isn't in many other reports.

    ReplyDelete
    Replies
    1. Nevermind, I didn't add the dataset to the report yet. Once I added the dataset (connected the RDP class to it) and deployed the report, it worked!

      Delete
  2. However, now the report runs, but the design that actually shows is the version I selected the previous time I ran the report. How can I get this to recognize the parameter I currently selected?

    ReplyDelete
    Replies
    1. Again nevermind, I didn't realize the class I duplicated was overriding the prePROMPTModifyContract method. Of course, this method would take the values from last execution. Hopefully these wrongdoings of mine help other people too.

      Delete