How to Run Report Definition of BI Publisher in PeopleCode
/*————————————————————————————– */
/* You must reference an application package at the beginning of the event */
/*————————————————————————————– */
import PSXP_RPTDEFNMANAGER:*;
Local Record &rcdQryPrompts;
Local string &LanguageCd, &MyTemplate, &MyReportName, &OutFormat, &State;
Local date &AsOfDate;
/*– Set XML Publisher report required parameters –*/
&LanguageCd = “THA”;
&AsOfDate = %Date;
&OutFormat = “PDF”;
/* ————————————————— */
/* Create a PDF using XML Report Definition */
/* —————————————————- */
&MyReportName = “Report Name”;
&MyTemplate = “TemplateName”;
/* ————————————————————————————- */
/* Hard code my State value – would normally pull from a field on the page */
/* ————————————————————————————- */
&EMPLID = Record.EMPLID;
&YEAR = Record.YEAR;
&SEQ = Record.SEQ;
/* —————————————————————————– */
/* Declare and Instantiate (construct) your Report Definition Object */
/* —————————————————————————– */
Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);
/* —————————————————————————– */
/* Get a handle on your Report Definition */
/* —————————————————————————– */
&oReportDefn.Get();
/* —————————————————————————– */
/* Since there is a prompt to the query used in this report, you need to */
/* provide the value for the prompt */
/* —————————————————————————– */
&rcdQryPrompts = &oReportDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
&oReportDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
/* —————————————————————————– */
/* Provide a value to the State Prompt */
/* —————————————————————————– */
rem &rcdQryPrompts.PROCESS_INSTANCE.Value = &ProcessInstane;
&rcdQryPrompts.EMPLID.Value = &EMPLID;
&rcdQryPrompts.YEAR.Value = &YEAR;
&rcdQryPrompts.SEQ.Value = &SEQ;
End-If;
/* —————————————————————————– */
/* Kick of the report process */
/* —————————————————————————– */
&oReportDefn.ProcessReport(&MyTemplate, &LanguageCd, &AsOfDate, &OutFormat);
/* —————————————————————————– */
/* CommitWork must be called prior to displaying the output since the */
/* application package performed work and SQL statements. If you do */
/* not commit the work performed to this point you will receive an */
/* error like “Think-time PeopleCode event (ViewAttachment), but a SQL */
/* update has occurred in the commit interval. (2, 148)” */
/* —————————————————————————– */
CommitWork();
/* —————————————————————————– */
/* Display Report to the user */
/* —————————————————————————– */
&oReportDefn.DisplayOutput();