FYI... on the last post I had incorrectly talked about case-sensitivity. For .NET Classes, the ABL is case-insensitive. You don't need to match the case when you reference classes.
(Also, I noted a few typos in my code sample which I corrected.)
this post as spam/abuse.
Architect of the SmartComponent Library and WinKit
Can you share the error message? I am wondering if you have the correct "USING" statement. The code above where you CAST (myReportDataSource, CsvDataSource) only works if the namespace for
CsvDataSource can be resolved.
The full class name is "Telerik.Reporting.CsvDataSource"
There is a section in the OpenEdge online documentation in this:
C# .NET code mapped to OpenEdge GUI for .NET ABL
You want to look at the section on Casting. Approximately, your code should look like.
DEFINE PUBLIC VAR myReport Report NO-UNDO.
DEFINE PUBLIC VAR csvDataSource AS CsvDataSource NO-UNDO.
myReport = new Report().
csvDataSource = CsvDataSource().
csvDataSource = CAST(myReport:DataSource, CsvDataSource).
(Note: in your cut/pasted code, you also had referred to the CvsDataSource CLASS as 'Telerik.Reporting.cvsDataSource" with different capitalization. For .NET components, the case is important. If you could share the error, it might point to which one of
the above problems you were running into.)
Thanks for the error message.
The issue is that you are trying to use CAST (object, class) with two objects. The second paramter is not the 'instance', but the class reference. Thjis is definitely not 'obvious' if you are not used to OOABL programming and .NET.
myDataSource = CAST(report:DataSource, myDataSource).
myDataSource = CAST(report:DataSource, Telerik.Reporting.CvsDataSource).
The code sample in the forum post earlier shows a more complete sample (Look at in in a browser, The content was edited after the post so the email content is out of date)
I am catching up with the ABL syntax, so here is a runnable tested ABL version of the originally provided code (Sample 1, 2, 3)
Note that you need to replace the actual paths to your report definition and runtime csv data.
/* Deserialize the report instance from the report definition trdx */
DEFINE VARIABLE xmlSettings AS System.Xml.XmlReaderSettings.
xmlSettings = NEW System.Xml.XmlReaderSettings().
xmlSettings:IgnoreWhitespace = TRUE.
DEFINE VARIABLE xmlReader AS System.Xml.XmlReader.
xmlReader = System.Xml.XmlReader:Create("C:\Work\Research\trdx\CsvReport.trdx", xmlSettings).
DEFINE VARIABLE xmlSerializer AS Telerik.Reporting.XmlSerialization.ReportXmlSerializer.
xmlSerializer = NEW Telerik.Reporting.XmlSerialization.ReportXmlSerializer().
DEFINE VARIABLE reportInstance AS Telerik.Reporting.Report.
reportInstance = CAST(xmlSerializer:Deserialize(xmlReader), Telerik.Reporting.Report).
/* Modify the report instance as needed */
DEFINE VARIABLE csvDataSource AS Telerik.Reporting.CsvDataSource.
csvDataSource = CAST(reportInstance:DataSource, Telerik.Reporting.CsvDataSource).
csvDataSource:Source = NEW System.Uri("C:\Work\Research\trdx\ds.txt").
/* Use the modified in-memory report definition in my app */
DEFINE VARIABLE instanceReportSource AS Telerik.Reporting.InstanceReportSource.
instanceReportSource = NEW Telerik.Reporting.InstanceReportSource().
instanceReportSource:ReportDocument = reportInstance.
THIS-OBJECT:reportViewer1:ReportSource = instanceReportSource.
Hope this helps.