Thursday 10 March 2016

How to Convert SSRS Report into PDF By using X++.

Here is the code to convert SSRS report into PDF.
But Before converting the report to PDF we need to send the parameter values to Contract class after that we need to convert the report.

//For Converting Report to PDF
public void makeCommissionReport()
{
    Args                            args;
    SrsReportRunInterface           reportRun;
    SrsReportDataContract           contract;
    SrsReportRunController          controller;
    CommByAgencyContract            commContract;
    SRSPrintDestinationSettings     printSettings;
    SRSReportExecutionInfo          executionInfo;



    SrsReportRunImpl                srsReportRun;

    ReportName                      reportname =  "CommissionReportAgency.report";
    filenameType    = '.pdf';
    generatedReportFilePath = filePath + file + filenameType;
    args = new Args();
   /* args.record(record);
    retailStoretable = args.record(record);
    generatedDocument = false;
   */
    /*select custTable where custTable.AccountNum == retailStoretable.DefaultCustAccount;
    storenum = retailStoretable.StoreNumber;
    num      = custTable.InvoiceAccount;
    */
    controller = new SrsReportRunController();
    controller.parmReportName(reportname);
    commContract = controller.parmReportContract().parmRdpContract();
    commContract.parmfromdate(dat);
    commContract.parmTodate(endDate);
    commContract.ReciD(recid);
    controller.parmArgs(args);
    srsReportRun = controller.parmReportRun() as SrsReportRunImpl;
    controller.parmReportRun(srsReportRun);

    controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
    controller.parmReportContract().parmPrintSettings().overwriteFile(true);
    controller.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
    controller.parmReportContract().parmPrintSettings().fileName(generatedReportFilePath);
    controller.runReport();
    //generatedDocument = true;
}

No comments:

Post a Comment