/********************************************************************************
SAMS_BRD220X Michael Nitschke 12/05/2011 XML Publisher
Common Class for XML Publisher
Users can use the method CreateXMLFilesFromRS to create only XML and XSD file,
very useful for XMLPublisher Template creation.
The PublishXMLReportFromRS method will create the XML Files and publish the given
report.
********************************************************************************/
import PSXP_XMLGEN:*;
import PSXP_RPTDEFNMANAGER:*;
class XMLPublisher
method XMLPublisher();
method PublishXMLReportFromRS();
method CreateXMLFilesFromRS();
property Rowset rsData;
property string sFileNameXSD;
property string sFileNameXML;
property string sRptDefn;
property string sReportTemplate;
property number processInstance;
property string xmlFileName;
end-class;
method XMLPublisher
/* Constructor. */
end-method;
/* Takes the rsData rowset property and uses it to publish a report, using other property values. */
method PublishXMLReportFromRS
%This.CreateXMLFilesFromRS();
/* Generate the report. */
Local any &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn); /* report definition name */
&oRptDefn.Get();
&oRptDefn.SetRuntimeDataXMLFile(%This.xmlFileName); /* Connect report and data. */
&oRptDefn.ProcessReport(&sReportTemplate, %Language_User, %Date, ""); /* report's template ID */
&oRptDefn.OutDestination = %FilePath;
/* Publish to Report Manager. */
&oRptDefn.Publish("", "", "", &processInstance);
end-method;
method CreateXMLFilesFromRS
/* Create XSD file. */
Local PSXP_XMLGEN:RowSetDS &oXML_GENERATOR = create psxp_xmlgen:RowSetDS();
Local string &my_schema = &oXML_GENERATOR.getXSDSchema(&rsData);
Local File &XSD_File = GetFile(&sFileNameXSD, "W");
&XSD_File.WriteLine(&my_schema);
&XSD_File.Close();
/* Create XML file. */
Local string &my_xml = &oXML_GENERATOR.getXMLData(&rsData, "");
Local File &XML_File = GetFile(&sFileNameXML, "W");
&XML_File.WriteLine(&my_xml);
%This.xmlFileName = &XML_File.Name;
&XML_File.Close();
end-method;
XML Publisher and Rowset Class
Posted by
Michael Nitschke
on Wednesday, 18 May 2011
Labels:
XML Publisher App Package Class
Example Class for an Application Package. Takes a Rowset and passes to the given Publisher Report and Template.
0 comments:
Post a Comment