X++ Pass SSRS query ranges
This method works fine on the job and also once the batch job or on the server
public void getSSRSReport(Filename filename,FilePath filepath )
{
Query reportRunQuery;
str querykey;
// filename = "Report.pdf";
//filename = filepath + filename;
this.parmReportName(ssrsReportStr(Report,Autodesign));
querykey = this.getFirstQueryContractKey();
this.parmReportContract().parmQueryContracts().remove(querykey);
reportRunQuery = new Query(queryStr(query name));
SrsReportHelper::addParameterValueRangeToQuery(reportRunQuery, tableNum(UserInfo),fieldNum(UserInfo, id),"abc.da");
this.parmReportContract().parmQueryContracts().insert(querykey, reportRunQuery);
this.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
this.parmReportContract().parmPrintSettings().overwriteFile(true);
this.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
this.parmReportContract().parmPrintSettings().fileName(filename);
this.parmShowDialog(false);
this.runReport();
}
-------------------------------------------------------------------
another way to run report and change the report query to get the data but
this does work when tested on the job. But gives error when run on the batch (or server).
srsreportrun class gives error when used in the batch and run on the server.
error seen: run on the client and report path method error.
public void getReport()
{
//#define.reportName(reportStr(Report.AutoDesign)); // report Name
QueryBuildRange queryBuildRange;
QueryBuildDatasource queryBuildDatasource,qbds;
SRSReportRun srsReportRun;
SrsReportRunController controller;
Query reportRunQuery;
filename = "Report.pdf";
filename = filepath + filename;
srsReportRun = new SRSReportRun();
controller = new SrsReportRunController();
//controller.callContractInterfaceMethod(classNum(SRSReportRun));
// srsReportRun.reportName(reportStr(Report.AutoDesign));
srsReportRun.init();
srsReportRun.resetQueries(); // reset the query
reportRunQuery = srsReportRun.reportQueries().lookup(srsReportRun.currentQueryKey());
if (srsReportRun.isInitialized()) // prompt the parameters form
{
queryBuildDatasource = SysQuery::findOrCreateDataSource(reportRunQuery, tablenum(UserInfo));
queryBuildRange = SysQuery::findOrCreateRange(queryBuildDatasource, fieldnum(UserInfo, id));
queryBuildRange.value(userData);
queryBuildRange.status(RangeStatus::Hidden);
// controller.parmReportRun().parmReportContract().parmQueryContracts().rangeSet():
//srsReportRun.saveSettings();
// srsReportRun.reportName();
//srsReportRun.reportPath();
srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
srsReportRun.printDestinationSettings().overwriteFile(true);
srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
srsReportRun.printDestinationSettings().fileName(filename);
srsReportRun.saveSettings();
//controller.parmReportRun().
srsReportRun.run();
}
}
public void getSSRSReport(Filename filename,FilePath filepath )
{
Query reportRunQuery;
str querykey;
// filename = "Report.pdf";
//filename = filepath + filename;
this.parmReportName(ssrsReportStr(Report,Autodesign));
querykey = this.getFirstQueryContractKey();
this.parmReportContract().parmQueryContracts().remove(querykey);
reportRunQuery = new Query(queryStr(query name));
SrsReportHelper::addParameterValueRangeToQuery(reportRunQuery, tableNum(UserInfo),fieldNum(UserInfo, id),"abc.da");
this.parmReportContract().parmQueryContracts().insert(querykey, reportRunQuery);
this.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
this.parmReportContract().parmPrintSettings().overwriteFile(true);
this.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
this.parmReportContract().parmPrintSettings().fileName(filename);
this.parmShowDialog(false);
this.runReport();
}
-------------------------------------------------------------------
another way to run report and change the report query to get the data but
this does work when tested on the job. But gives error when run on the batch (or server).
srsreportrun class gives error when used in the batch and run on the server.
error seen: run on the client and report path method error.
public void getReport()
{
//#define.reportName(reportStr(Report.AutoDesign)); // report Name
QueryBuildRange queryBuildRange;
QueryBuildDatasource queryBuildDatasource,qbds;
SRSReportRun srsReportRun;
SrsReportRunController controller;
Query reportRunQuery;
filename = "Report.pdf";
filename = filepath + filename;
srsReportRun = new SRSReportRun();
controller = new SrsReportRunController();
//controller.callContractInterfaceMethod(classNum(SRSReportRun));
// srsReportRun.reportName(reportStr(Report.AutoDesign));
srsReportRun.init();
srsReportRun.resetQueries(); // reset the query
reportRunQuery = srsReportRun.reportQueries().lookup(srsReportRun.currentQueryKey());
if (srsReportRun.isInitialized()) // prompt the parameters form
{
queryBuildDatasource = SysQuery::findOrCreateDataSource(reportRunQuery, tablenum(UserInfo));
queryBuildRange = SysQuery::findOrCreateRange(queryBuildDatasource, fieldnum(UserInfo, id));
queryBuildRange.value(userData);
queryBuildRange.status(RangeStatus::Hidden);
// controller.parmReportRun().parmReportContract().parmQueryContracts().rangeSet():
//srsReportRun.saveSettings();
// srsReportRun.reportName();
//srsReportRun.reportPath();
srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
srsReportRun.printDestinationSettings().overwriteFile(true);
srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
srsReportRun.printDestinationSettings().fileName(filename);
srsReportRun.saveSettings();
//controller.parmReportRun().
srsReportRun.run();
}
}
Comments
Post a Comment