SAVE REPORT TO PDF FROM AX JOB CONTROLLER CLASS : VIKAS MEHTA
HOW TO CALL A REPORT FROM JOB AND SAVE IT IN PDF
public static void
SaveReportToPDFFromController(Args _args)
{
VIKSalesInvoiceFinanceController salesInvoiceController;
VIKSalesInvoiceFinanceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
SRSReportExecutionInfo reportExecutionInfo;
ReportName reportName = "VIKSalesFinance.PrecisionDesign1";//PrecisionDesign1_backup
#define.ReportName('VIKSalesFinance.PrecisionDesign1')
;
//SRSReportExecutionInfo = new
SRSReportExecutionInfo();d
select firstOnly custInvoiceJour where custInvoiceJour.SalesId
== "1234”;
args.record(custInvoiceJour);
salesInvoiceController = new VIKSalesInvoiceFinanceController();
salesInvoiceController.parmReportName(reportName);
reportExecutionInfo =
salesInvoiceController.parmReportContract().parmReportExecutionInfo() as
SrsPrintMgmtExecutionInfo;
if (!reportExecutionInfo)
{
reportExecutionInfo = new
SrsPrintMgmtExecutionInfo();
}
//reportExecutionInfo.parmOriginalDestinationFileName("c:\\SalesInvoice.pdf");
salesInvoiceContract =
salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmReportCopyName('');
salesInvoiceContract.parmTenderTypeId('21');
salesInvoiceContract.parmInvoiceId(custInvoiceJour.InvoiceId);
salesInvoiceContract.parmSalesId(custInvoiceJour.SalesId);
// salesInvoiceContract.
// salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record
id must be passed otherwise the report will be empty
// salesInvoiceContract.parmInvoiceIdparm(custInvoiceJour.RecId); //
Record id must be passed otherwise the report will be empty
salesInvoiceController.parmArgs(args);
salesInvoiceController.parmReportName(#ReportName);
salesInvoiceController.parmDialogCaption("Sales Finance
Invoice");
args.parm(strFmt("Copy - 1"));
srsReportRun =
salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmReportExecutionInfo(reportExecutionInfo);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName("c:\\test123\\SREPORT.pdf");
salesInvoiceController.runReport();
}
static void SaveReportToPDFFromController(Args
_args)
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
SRSPrintDestinationSettings settings;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName =
"SalesInvoice.Report";
;
select firstOnly custInvoiceJour where
custInvoiceJour.invoiceid == "sid";
args.record(custInvoiceJour);
salesInvoiceController = new
SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract =
salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id
must be passed otherwise the report will be empty
//
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// comment this code if tested in pre release
salesInvoiceController.parmArgs(args);
srsReportRun =
salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportName(ssrsReportStr(VIKSalesFinance,
PrecisionDesign1));
// Use execution mode appropriate to your
situation
//
salesInvoiceController.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
// Suppress report dialog
salesInvoiceController.parmShowDialog(false);
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName("c:\\VIKAS\\sdc.pdf");
settings =
salesInvoiceController.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(@'c:\\TEST\1234.pdf');
salesInvoiceController.startOperation();
}
No comments:
Post a Comment