indigomage
asked on
How to Programatically Access Sage Reports from within Delphi
Hi All,
I'm currently accessing Sage (V15) from Delphi 7, and want to print a report at the end of a process. Can some one let me have some sample code that does this in Delphi (version doesn't matter) I don't want to create a new report, I just want to print a report that already exists (a purchase order if it matters)
Regards
Smurf
I'm currently accessing Sage (V15) from Delphi 7, and want to print a report at the end of a process. Can some one let me have some sample code that does this in Delphi (version doesn't matter) I don't want to create a new report, I just want to print a report that already exists (a purchase order if it matters)
Regards
Smurf
ASKER
Yes Sage Line 50 UK Version.
I've got examples in VB.NET, and C#. NET, but as they are both .NET that doesn't help.
I don't necessarily want to run the report IN Sage I just want to run the Sage report without requiring input from the user (who probably won't have sage open)
I've got examples in VB.NET, and C#. NET, but as they are both .NET that doesn't help.
I don't necessarily want to run the report IN Sage I just want to run the Sage report without requiring input from the user (who probably won't have sage open)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Doesn't really answer the problem, but if it's not possible, then I'll accept it. Although as I said I have code for doing it in VB.Net and C#.Net.
can you post the examples?
ASKER
Hi Bruce,
Not sure why I never replied to this, I think I moved on to another project, but have now run into a similar question (for a different reason, but the same request: select and print a Sage report whilst accessing sage remotely).
I have since found that the version of sage I am using supports remote reporting, but the examples don't support delphi. So here are examples of the two pieces of code I need converted to allow me to access the reports. The first snippit is a class that needs to be available to the second, but I can sort out where to put it once it is delphi code. I've looked at the various c# to Delphi converters, but they all want to convert to .net, and I'm using v7 which doesn't to that :-) anyway, the examples:
Regards
Smurf
Not sure why I never replied to this, I think I moved on to another project, but have now run into a similar question (for a different reason, but the same request: select and print a Sage report whilst accessing sage remotely).
I have since found that the version of sage I am using supports remote reporting, but the examples don't support delphi. So here are examples of the two pieces of code I need converted to allow me to access the reports. The first snippit is a class that needs to be available to the second, but I can sort out where to put it once it is delphi code. I've looked at the various c# to Delphi converters, but they all want to convert to .net, and I'm using v7 which doesn't to that :-) anyway, the examples:
public class MyHost : Sage.Reporting.Engine.Integration.IReportingEngineHost
{
private Sage.Reporting.Engine.Integration.IReportingEngineSite _oSite;
public object GetService(Guid identifier)
{
return null;
}
public Sage.Reporting.Engine.Integration.IReportingEngineSite Site
{
get { return _oSite; }
set { _oSite = value; }
}
}
and
string szReportsPath = @"C:\Documents and Settings\All Users\Application"
+ "Data\Sage\Accounts\2010\Demodata\Reports";
Sage.Reporting.Engine.Integration.IReportingEngineHost oHost;
Sage.Reporting.Engine.Integration.ReportingEngine oEngine;
Sage.Reporting.Engine.Integration.IReportingEngineSite oSite;
Sage.Reporting.Engine.Integration.IReportInformationService oInformationService;
// Instantiate Reporting objects
oHost = new MyHost();
oEngine = new Sage.Reporting.Engine.Integration.ReportingEngine();
oSite = oEngine.CreateInstance(oHost);
oInformationService = oSage.Reporting.Engine.Integration.IReportInformationService)oSite.GetService
(Sage.Reporting.Engine.Integration.ServiceIdentifiers.ReportInformation);
// Cycle through all report files and display their details
foreach (string szReportFilePath in System.IO.Directory.
GetFiles(szReportsPath, "*.report", System.IO.SearchOption.AllDirectories))
{
// Create Report Information Service and return report details
Sage.Reporting.Engine.Integration.IReportInformation oInformation =
oInformationService.GetInformation(szReportFilePath);
string szReportName = oInformation.GetAttribute("Name").ToString();
string szReportDescription =
oInformation.GetAttribute("Description").ToString();
string szReportLastRun = oInformation.GetAttribute("LastRunDate").ToString();
// This example assumes that a listbox control named listBox1
// has been added to the form
listBox1.Items.Add(string.Format
("Report name: {0}, Description: {1}, Last Run Date: {2}",
szReportName, szReportDescription, szReportLastRun));
}
Regards
Smurf
Where did you find this?
ASKER
My Sage Developer Help File for Sage 2013
I had assumed you did not have the developer kit. As you have spent all that money on the Developer Kit you should address this with the Sage developer support staff.
(You also need to be a little careful Sage get a bit fussy about confidential information being leaking into the public domain)
The sample code shows how to list reports, not how to run reports, you might also want to run layouts, labels, letters.
Sage may use this internally to run reports from Sage 50, but there are a couple of issues that prevent you from using it as you might like.
First some reports pop up a user dialogue to make criteria selections, the other is that you need to pass parameters as criteria to the report (or layout) and Sage have never documented how to use the engine to run a report.
I am sorry but this is not going to work without a lot of hacking.
I don't know of anyone who has run a report programatically.
I would write the report externally.
(You also need to be a little careful Sage get a bit fussy about confidential information being leaking into the public domain)
The sample code shows how to list reports, not how to run reports, you might also want to run layouts, labels, letters.
Sage may use this internally to run reports from Sage 50, but there are a couple of issues that prevent you from using it as you might like.
First some reports pop up a user dialogue to make criteria selections, the other is that you need to pass parameters as criteria to the report (or layout) and Sage have never documented how to use the engine to run a report.
I am sorry but this is not going to work without a lot of hacking.
I don't know of anyone who has run a report programatically.
I would write the report externally.
ASKER
Ok, thanks bruce
You can not run a report in sage pro-grammatically to my knowledge.