Following is a sample code for generating SSRS report in PDF format using X++ code. This sample code generates Purchase order confirmation report in PDF format and saves it into specified location.
PSAPurchaseOrderController poConfirmationController;
PurchPurchaseOrderContract purchPOContract;
SRSReportExecutionInfo reportExecutionInfo;
Args args = new Args();
SrsReportRunImpl srsReportRun;
VendPurchOrderJour vendPurchOrderJour;
ReportName reportName = ssrsReportStr(PSAPurchaseOrder, Report);
str fileName;
;
select firstOnly vendPurchOrderJour
order by RecId desc
where vendPurchOrderJour.PurchId == '';//Replace with PurchOrder Id
if (!vendPurchOrderJour)
return '';
args.record(vendPurchOrderJour);
poConfirmationController= PSAPurchaseOrderController::construct();
poConfirmationController.parmArgs(args);
poConfirmationController.parmReportName(reportName);
reportExecutionInfo = poConfirmationController.parmReportContract().parmReportExecutionInfo();
purchPOContract= poConfirmationController.parmReportContract().parmRdpContract();
purchPOContract.parmRecordId(vendPurchOrderJour.RecId); // Record id must be passed otherwise the report will be empty
poConfirmationController.parmArgs(args);srsReportRun = poConfirmationController.parmReportRun() as SrsReportRunImpl;
fileName = System.IO.Path::Combine(WinAPIServer::getTempPath(), strFmt('purchConfirmation_%1.pdf', _purchId));
poConfirmationController.parmReportRun(srsReportRun);
poConfirmationController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);poConfirmationController.parmReportContract().parmPrintSettings().overwriteFile(true);
poConfirmationController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
poConfirmationController.parmReportContract().parmPrintSettings().fileName(fileName);
poConfirmationController.runReport();