Sample App Package for BI Publisher Class in AE/PeopleCode

 * ************************ */

/* GENERATE XML & XSD FILES */

/* ************************ */


import PSXP_XMLGEN:RowSetDS;
class reportStructure
/* Constructor */
method reportStructure();
/* Generates an XSD based on a rowset */
method generateXsdFile(&aRowset As Rowset, &anXSDfile As string);
/* Generates an XML based on a rowset */
method generateXmlFile(&aRowset As Rowset, &anXMLFileName As string);
end-class;
method reportStructure
end-method;
method generateXsdFile
/+ &aRowset as Rowset, +/
/+ &anXSDfile as String +/
Local PSXP_XMLGEN:RowSetDS &rowsetDS;
Local File &fileXSD;
Local string &strSchema;
&rowsetDS = create psxp_xmlgen:RowSetDS();
&strSchema = &rowsetDS.getXSDSchema(&aRowset);
&fileXSD = GetFile(&anXSDfile, "W", %FilePath_Relative);
&fileXSD.WriteLine(&strSchema);
&fileXSD.Close();
end-method;
method generateXmlFile
/+ &aRowset as Rowset, +/
/+ &anXMLFileName as String +/
Local PSXP_XMLGEN:RowSetDS &rowsetDS;
Local File &filTmp;
Local string &strXML;
&filTmp = GetFile(&anXMLFileName, "W", "UTF-8", %FilePath_Absolute);
If &filTmp.IsOpen Then
&rowsetDS = create psxp_xmlgen:RowSetDS();
&strXML = &rowsetDS.getXMLData(&aRowset, "");
&filTmp.WriteLine(&strXML);
&filTmp.Close();
End-If;
end-method;
/* ****************** */
/* PRINT REPORT CLASS */
/* ****************** */
import PSXP_RPTDEFNMANAGER:ReportDefn;
class createReport
/* constructor */
method createReport();
/*  Rowset-based report, triggered from an Application Engine */
method buildRptFromAE(&aRptName As string, &aTmplName As string, &aFileOutput As string, &anXMLFileName As string, &anOutFormat as number);
/* Rowset-based report, triggerd from a page */
method buildRptOnLine(&aRptName As string, &aTmplName As string, &aFileOutput As string, &anXMLFileName As string, &anOutFormat as number);
end-class;
/* constructor */
method createReport
end-method;
/**************************************************************/
/* Rowset-based report, triggered from an Application Engine  */
/**************************************************************/
method buildRptFromAE
/+ &aRptName as String, +/
/+ &aTmplName as String, +/
/+ &aFileOutput as String, +/
/+ &aFileXmlName as String, +/
/+ &anOutFormat as Number +/
Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn;
Local date &dtAsOfDate;
Local string &strLangCD, &strOutFormat;
/* Instanciar Reporte */
&oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&aRptName);
&oReportDefn.Get();
/* Idioma, fecha y formato de impresiĆ³n */
&strLangCD = %Language_User;
&dtAsOfDate = %Date;
rem &nbrOutFormat = %OutDestFormat;
&strOutFormat = &oReportDefn.GetOutDestFormatString(&anOutFormat);
&oReportDefn.UseBurstValueAsOutputFileName = True;
&oReportDefn.SetRuntimeDataXMLFile(&aFileXmlName);
rem &oReportDefn.OutDestination = &anXMLPath;
&oReportDefn.ReportFileName = &aFileOutput;
&oReportDefn.ProcessReport(&aTmplName, &strLangCD, &dtAsOfDate, &strOutFormat);
end-method;


/*********************************************/

/* Rowset-based report, triggerd from a page */

/*********************************************/

method buildRptOnLine

/+ &aRptName as String, +/

/+ &aTmplName as String, +/

/+ &aFileOutput as String, +/

/+ &aFileXmlName as String, +/

/+ &anOutFormat as Number +/


Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn;

Local string &strLangCD, &strOutFormat;

Local date &dtAsOfDate;


/* Instanciar Reporte */

&oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&aRptName);

&oReportDefn.Get();


/* Idioma, fecha y formato de impresiĆ³n */

&strLangCD = %Language_User;

&dtAsOfDate = %Date;

&strOutFormat = &oReportDefn.GetOutDestFormatString(&anOutFormat);

&oReportDefn.UseBurstValueAsOutputFileName = True;

&oReportDefn.SetRuntimeDataXMLFile(&aFileXmlName);

rem &oReportDefn.OutDestination = &anXMLPath;

&oReportDefn.ReportFileName = &strFileOutput;

&oReportDefn.ProcessReport(&strTemplate, &strLangCD, &dtAsOfDate, &strOutFormat);

/* Publicar reporte*/

CommitWork();

/* Mostrar salida en otra ventana */

&oReportDefn.DisplayOutput();

end-method;

No comments:

Post a Comment

PeopleCode to retrieve Google map between two addresses

  PeopleCode Example: /* Define constants for the API request */ Local string &origin = "123 Main St, Anytown, USA";   /* ...