Mittwoch, 17. Dezember 2014

Dynamics AX 2012 SSRS Reports


Create a new SSRS Report:


1. Create the temporary table for the Report 
 -> ReportTableTMP, ReportLineTMP
-> Set the Parameter TableType to InMemory or TempDB


2. Create the classes for Controller, Contract and Dataprovider


The Controller-Class
public class Report_Controller extends SrsReportRunController
{
}
public static void main(Args _args)
{
    Report_Controller controller;
    CustInvoiceTrans   CustInvoiceTrans;
    ;
Report_Contract    contract = new Report_Contract();
Controller = new Report_controller();
Controller.parmReportName(SSRSReportSTr(ReportNAME),DESIGNName));
Controller.parmArgs(_args);
controller.parmLoadFromSysLastValue(false);
controller.parmShowDialog(false);  //No Dialog
CustInvoiceTrans   = _args.record();

contract.parmCustInvoiceTrans(CustInvoiceTrans);
Controller.parmReportContract().parmRdpContract(contract);
Controller.startOperation();
}





The Contract-Class
[DataContractAttribute]
public class Report_Contract
{
   CustInvoiceTrans    CustInvoiceTrans;
}
and the parmMethode for CustInvoiceTrans...


The Dataprovider -Class


[SRSReportParameterAttribute(classStr(Report_Contract))] <-- These Parameter are necessary


public class ReportDP extends SRSReportDataProviderBase
{
       ReportTableTmp    TableTMP;
       REportLineTmp     LineTmp;
}


[SRSReportDataSetAttribute(tableStr(ReportTableTmp))]


public ReportTableTmp getReportTableTmp()  <-- you Need this for every temporary table you want to use in the Report
{
       select * from ReportTableTmp ;


       return ReportTableTmp ;
}

[SRSReportDataSetAttribute(tableStr(ReportLineTmp))]


public ReportLineTmp getReportLineTmp()
{
       select * from ReportLineTmp;


       return ReportLineTmp;
}

 

[SysEntryPointAttribute]
public void processReport()
{
    REportContract contract;
    ;
    contract = this.parmDataContract();
    CustInvoiceTrans = contract.parmCustInvoiceTrans();
   
    //Fill the ReportTableTMP
    //Fill the ReportLineTMP
}



The MenuItem parameter for the Report





How to call the Report from Code


private void printReport()
{
    SRSPrintDestinationSettings printSettings;
    Report_contract contract = new Report_contract();
    Report_controller controller = new Report_controller();
    ;
    // set Report Name
    controller.parmReportName(ssrsReportStr(ReportNAme,DesignName));

    // set contract
    contract.parmCustInvoiceTrans(CustInvoiceTrans);
    controller.parmReportContract().parmRdpContract(contract);

    // get Print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    // set print medium
    printSettings.printMediumType(SRSPrintMediumType::Screen);

    // supress dialog
    controller.parmShowDialog(false);

    // run report
    controller.startoperation();

}


And now only the Report is missing.



Keine Kommentare:

Kommentar veröffentlichen