How do I export an SSRS report to a pdf file in a batch job using X++? - reporting-services

Is it possible to generate an SSRS report in Dynamics AX 2009 and save it as a pdf file using X++ ?
The problem I have is that I need to generate the data for the report and then generate the report. Reporting server subscriptions wont work in this case as there is no way for them to call the x++ to generate the data.
I have also had a look at passing the rendering type to the SSRS report in the URL, but it doesnt seem to accept a filename to save the report as.
The logic that generates the data is not a straightforward query, and takes quite a while to run. I want to be able to turn this into a batch process so that several reports can be generated by a batch server.

Ensure that AX is configured as a batch server and then you will need to create a batch job.
The art of creating a batch class (for the batch job to call) which calls a report and generates a pdf file overnight has already been mastered here.
The following snippet for generating a PDF file is from the class EPSendDocument.makeDocument()
Filename file = "\\\\Server\\SharedFolder\\File.pdf";
printSettings = reportRun.parmReportContract().parmPrintSettings();
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.fileName(file);
printSettings.overwriteFile(true);
Another link for converting a report to a pdf file.
Finally do check first if the files are generated by executing the class from within your AX client, and then when it is run on the batch server. There may be permission or path issues.

Related

Corrupted SSRS report rendered when generated from SSIS

I have an SSIS 2008 package that is reading data from multiple excel files, performing transformation and generating output in an excel file. I'm then using that output excel file as data source to call an SSRS 2008 report hosted on localhost through the same SSIS package as Script Task and exporting it as pdf and xls reports. The reports are getting generated but are of small size and corrupted.
When I run the same report from BIDS 2008 and export it to pdf or xls, it works fine.
The report has one parameter. SSIS execute script task is contained in a foreach loop container and passes that parameter one-by-one to generate 30 odd reports.
Would appreciate if someone could provide some help on this.

How to load HTML data into SQL Server (non-table format)?

I'm posting it here because I couldn't' find any such scenario on the web so far. I have a webpage which contains a set of reports both in XLS and PDF formats. I should be downloading the excel files from the page and load into my database. I wish I could use the URL for XLS file directly but the problem is the naming convention may keep changing every time (Sales_Quarter1.xlsx can be Sales_Q1.xlsx the next year). The only thing that would be constant in the following example is "Sales for Calendar Year". I should be looking up for the file that corresponds to this text and download it before loading it into database table.
I would like to know from experts if this would be possible?
<li>
<sub>Sales for Calendar Year 2015--All Countries </sub>
<a href="/Data/Downloads/Documents/Sales/Sales_Quarter1.xlsx">
<sub>[XLS]</sub></a><sub> , <sub>[PDF]</sub><sub>​</sub></sub>
</li>
PS: I am using SQL Server 2014.
Thanks!
Have a look at Integration Services. Create a package for both pulling the web page using a script task, along with a variable name that will represent your downloaded, local filenames for the html file and excel files (you will also have to parse the link out of the html file). Then utilize an Excel Source next in your package.
The variable name for the excel file used in the script task will need to be set to ReadWrite as well.
You can also schedule the resulting package execution via SQL Agent job, if you plan to run this on a reoccurring basis, placing logic into the script or the execution paths,

Output/export information from configmgr 2012 ssrs report

I understand it is possible to export the report data into multiple file types using the export button. however i'm wanting to access the information without having to manually export. So my question is, is it possible using a batch file or powershell to read a text box on the report and output it say into a notepad file or spreadsheet. or if not maybe just a way to export all of the data on the report without having to manually do it? Screenshot attached for an example.
One option is to create a subscription for the report and either have an attachment emailed to you or have it saved to a network location. In either case, there are several export options (csv, excel, xml, etc.). If you're only wanting partial data from the report, I'd recommend creating a sql query or just create a new report that gets you exactly what you need.

Force SSRS Report to create a file rather than render on screen

Using SSRS for SS 2008, is there a way to force the report to download rather than render? I have a report that has thousands of rows - rather than waste resources returning the resultset to the front end, I would rather just force the user to download a CSV or XLS file.
This is not a subscription-based report - rather, it is adhoc via a "click".
I think exporting using url might be your solution. Try the following :
http://localhost/ReportServer/Pages/ReportViewer.aspx?%2fSample+Report+Solution+R+and+D%2fGroupWise+Report&rs:Format=CSV

Error with shared dataset when manually download report and put into ReportViewer

I have a server report that references a shared dataset on the server. It works fine if I add a ReportViewer to a page and set the report server URL and report path properties.
Because I need to look at the xml of the report and do some preprocessing, I:-
Manually download the report using: ReportingService2010.GetItemDefinition(path). I then convert this to an XDocument.
Do my preprocessing - this does not touch anything to do with datasets.
Load the xml definition into the report viewer using:
XDocument processedDocument;
using (var sr = new StringReader(processedDocument.ToString()))
{
viewer.ServerReport.LoadReportDefinition(sr);
}
When I attempt to view the report, I see this error in the server error logs:
Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException:
Shared dataset definition stream does not exist.
To get to the crux of the error, I've removed step 2 completely so that all I am doing is downloading the report, converting to xml and then loading the xml into the ReportViewer.
I do not get this problem when the datasets are embedded in the report.
Any ideas what is happening here?
ETA:
If I download the report, convert to XDocument, convert back to byte[] and then use ReportingService2010.SetItemDefinition() to save the report on the server, it displays fine in the ReportViewer (when the path is specified).
This means the problem is not in the xml<->byte[] conversions. When the ReportViewer downloads a report, using a path, it must be doing something with the referenced shared datasets that I'm not doing.
I have a workaround.
It seems to be a problem with the relative path to the shared DataSets. I presume I would have the same problem referring to shared images on the server as well.
Here's what I intend to do:
Download the report.
Perform pre-processing.
Use ReportingServices2010.CreateCatalogueItem to save a new report back on the server at exactly the same location, but using a temporary name.
Use reportViewer.ServerReport.ReportPath to reference the new temporary report.
ETA:
Actually, because the DataSet path references always start at the root, I don't think you have to store the report at exactly the same location. You can create a /Temp folder that you can easily periodically clean out.